0
1
2
3
4
for
loopfor in range():
for x in string:
for x in list:
Modify your count_chars
function. Use for x in string
instead of for x in range(len(string))
.
for i in range(len(list)):
VS. for x in list:
option 1
(need to use index i
to mutate)both options
It returns a dictionary that maps each negative value in numbers
to its frequency in numbers
.
Iterating keys:
Another option: dict.keys()
:
Iterating values: dict.values()
:
10
25
27
10
Iterating both keys and values: dict.items()
It returns a list with all the keys and values in the dictionary
.
Test cases:
You have 10 minutes to complete the quiz.
No need to write main()
function.
It mutates dict_1
, by adding to it all key-values pairs in dict_2
. If a key is in both dictionaries, the values are added.
Test cases:
It mutate the list, multiply every number by 2. It returns the highest value in the mutated list.
Test cases:
line 3: can we use for x in list
?
line 5: can we use for i in range(len(list))
?
for x in list
?