Issue
For example, let's say I have a list:
integer_list = [1, 2, 3, 4]
and I want to plug each element of the list into a formula, like (x*5)+1. How would I do that? I cannot use for loops or lambda functions. I can't import any modules either. Right now I am quite literally doing integer_list[0] * 5 + 1
How would I then get the answer from that and multiply every item in the set by it?
Please help!
Solution
no lambda no cry
def f(x):
return (x*5)+1
result = list(map(f, integer_list))
Answered By - Kelly Bundy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.