Maps Flashcards

1
Q

Map()

A

Applies a function to each item in an lterable (list, tuple, dictionary . Etc)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly