File tree 6 files changed +37
-22
lines changed
13.4-Making_HTML_with_filter_and_maP 6 files changed +37
-22
lines changed Original file line number Diff line number Diff line change 5
5
``` py
6
6
Expexted:
7
7
< ul>< li> Red< / li>< li> Orange< / li>< li> Pink< / li>< li> Violet< / li>< / ul>
8
- ```
8
+ ```
9
+
10
+ # 💡Hint:
11
+ Maybe you have to use filter and map function
12
+ Set values to the news variables
Original file line number Diff line number Diff line change 10
10
11
11
#Your code go here:
12
12
13
- filter_colors = list (filter (lambda color : color ["sexy" ],all_colors ))
14
- general_li = list (map (lambda color : "<li>" + color ["label" ]+ "</li>" , filter_colors ))
15
- print ("<ul>" + '' .join (general_li ) + "</ul>" )
Original file line number Diff line number Diff line change
1
+ import io
2
+ import os
3
+ import sys
4
+ sys .stdout = buffer = io .StringIO ()
5
+
6
+ import app
7
+ import pytest
8
+
9
+
10
+ @pytest .mark .it ("Print the list of color in the console" )
11
+ def test_output ():
12
+ captured = buffer .getvalue ()
13
+ assert "\n " in captured
14
+
15
+
16
+ @pytest .mark .it ("Use the filter function" )
17
+ def test_filter ():
18
+ f = open (os .path .dirname (os .path .abspath (__file__ ))+ '/app.py' )
19
+ content = f .read ()
20
+ assert content .find ("filter" )
21
+
22
+
23
+ @pytest .mark .it ("Use map function" )
24
+ def test_map ():
25
+ f = open (os .path .dirname (os .path .abspath (__file__ )) + '/app.py' )
26
+ content = f .read ()
27
+ assert content .find ("map" )
Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ parking_state = [
14
14
```
15
15
16
16
# 📝Instructions
17
- 1 . Create a function get_parking_lot() that returns an object with total_slots, available_slots and occupied_slots like the following:
17
+ 1 . Create a function get_parking_lot() that returns an object
18
+ with total_slots, available_slots and occupied_slots like the following:
18
19
const state = {
19
20
totalSlots: 12,
20
21
availableSlots: 3,
@@ -23,3 +24,5 @@ const state = {
23
24
24
25
💡Hints
25
26
You have to do a nested loop
27
+ Declare a variables to store the value
28
+ Compare the statements
Original file line number Diff line number Diff line change 6
6
7
7
#Your code go here:
8
8
9
- total = []
10
- occupied = []
11
- available = []
12
- parking_slots = {}
13
-
14
- def get_parking_lot (spaces ):
15
- for numb in spaces :
16
- for digit in numb :
17
- total .append (digit )
18
- if digit == 1 :
19
- occupied .append (digit )
20
- elif digit == 2 :
21
- available .append (digit )
22
- parking_slots .update ({'total' : len (total ), 'occupied' : len (occupied ), 'available' : len (available )})
23
- return parking_slots
24
- print (get_parking_lot (parking_state ))
25
9
Original file line number Diff line number Diff line change 9
9
@pytest .mark .it ("Print the object" )
10
10
def test_output ():
11
11
captured = buffer .getvalue ()
12
- assert "\n " in captured
12
+ assert "{'total': 9, 'occupied': 5, 'available': 1} \n " in captured
13
13
14
14
@pytest .mark .it ("Create a get_parking_lot function" )
15
15
def test_function ():
You can’t perform that action at this time.
0 commit comments