How to use list comprehension on function with Python

1 Answer

0 votes
def f(x):
  return x * 4

lst = [f(x) for x in range(5)]

print(lst)



'''
run:

[0, 4, 8, 12, 16]

'''

 



answered Aug 22, 2019 by avibootz
...