1
2
3
4
5
6
7
8
9
10
11
12
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to Trinket.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11
0
0
0
0
To loop through a dictionary getting both its keys and values, what keyword do you use? | items | ^ *items *$ | |
Type the character that's missing in this code. | for each_key each_value in products.items(): | , | ^ *, *$ |
Complete the line to loop through the dictionary, getting both keys and values. | for x, y in z__________ | .items(): | .`items`(`)`: |
Code the first line to loop through z to get both keys and values. Assign keys to x and values to y. | for x, y in z.items(): | for x, y in z.items(): | |
Code the first line to loop through keys. Make everything up. | for state_or_province in cities.keys(): | ^ *for [a-zA-Z_][a-zA-Z0-9_]* in [a-zA-Z_][a-zA-Z0-9_]*\.keys\(\): *$ | |
Code the first line to loop through values. Make everything up. | for state_or_province in cities.values(): | ^ *for [a-zA-Z_][a-zA-Z0-9_]* in [a-zA-Z_][a-zA-Z0-9_]*\.values\(\): *$ | |
Code the first line to loop through a dictionary, getting both keys and values. Make everything up. | for city, province_or_state in countries.items(): | ^ *for [a-zA-Z_][a-zA-Z0-9_]*, [a-zA-Z_][a-zA-Z0-9_]* in [a-zA-Z_][a-zA-Z0-9_]*\.items\(\): *$ | |
Loop through a dictionary, getting both keys and values. Display the values. Make everything up. | for the_key, the_value in z.items(): print(the_value) |
^ *for [a-zA-Z_][a-zA-Z0-9_]*, ([a-zA-Z_][a-zA-Z0-9_]*) in [a-zA-Z_][a-zA-Z0-9_]*\.items\(\):\n print\(\1\) *$ | |
Loop through a dictionary, getting both keys and values. Display "The key is " and then the key. Remember to include a space at the end of the string. Make everything up. | for x, y in z.items(): print("The key is " + x) |
^ *for ([a-zA-Z_][a-zA-Z0-9_]*), [a-zA-Z_][a-zA-Z0-9_]* in [a-zA-Z_][a-zA-Z0-9_]*\.items\(\):\n print\(•The key is • \+ \1\) *$ | |
Loop through a dictionary, getting both keys and values. If you find an item that has the same key and value, display "weird" and break the loop. Make up the names of everything. | for x, y in z.items(): if x == y: print("weird") break |
^ *for ([a-zA-Z_][a-zA-Z0-9_]*), ([a-zA-Z_][a-zA-Z0-9_]*) in [a-zA-Z_][a-zA-Z0-9_]*\.items\(\):\n if \1 == \2:\n print\(•weird•\)\n break *$ | |
|
9c8a6b71df | ||
|
4db7c6a799 |