Question: def sizes(input): '''Returns a dictionary with the same keys as input but with list values replaced with their lengths.''' # TODO: Implement # DO NOT
def sizes(input):
'''Returns a dictionary with the same keys as input but with
list values replaced with their lengths.'''
# TODO: Implement
# DO NOT MODIFY BELOW THIS LINE
test1 = sizes({'a': [1,2,3], 'b': [1], 'c': [], 'd': [1,2,3,4]})
print(test1['a'])
print(test1['b'])
print(test1['c'])
print(test1['d'])

Implement the function sizes which takes in a dictionary with values that are lists and returns a new dictionary with the same keys but with values that are the lengths of the lists in the original dictionary. For example, sizes ({'a' : [1,2,3], 'b': [1]}) should return {'a' : 3, 'b': 1}. Your code VQUIDWN 1 def sizes ( input) : Returns a dictionary with the same keys as input but with list values replaced with their lengths. ''' # TODO: Implement # DO NOT MODIFY BELOW THIS LINE test1 = sizes ({'a': [1, 2,3 ], 'b': [1], 'c': [ ], 'd': [1,2,3,4]}) 8 print (testl [ 'a' ]) 9 print (testl [ 'b' ]) 10 print (testl [ 'c' ]) 11 print (testl [ 'd' ])|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
