Apply Functions to List Elements Using Comprehension

Python

 1|  original_list = [10,11,12,13]
 2|  
 3|  def multiply_by_10(x):
 4|      return x * 10
 5|  
 6|  new_list = [multiply_by_10(n) for n in original_list]
 7|  
 8|  new_list
Did you find this snippet useful?

Sign up for free to to add this to your code library