Maps Flashcards
1
Q
Map()
A
Applies a function to each item in an lterable (list, tuple, dictionary . Etc)
2
Q
Use the map function to double the money in this tuple:
Money = [(bank1,10), (bank2,20),(bank3,40)]
A
Double = Lambda cash:(cash[0], cash[1]*2)
Doubled_money = list(map(Double, Money))
For x in Doubled_money:
Print(x)
Output:
[(‘bank1’,20), (‘bank2’,40),(‘bank3’,80)]