using functions to display numbers in a list

后端 未结 4 1130
面向向阳花
面向向阳花 2021-01-29 14:09

I have a list of numbers and I have to use a function to display them in celsius, they are in fahrenheit now.

nums = [30,34,40,36,36,28,29,32,34,44,36,35,28,33,         


        
4条回答
  •  没有蜡笔的小新
    2021-01-29 14:31

    If you have a list the_list and you want to apply a function f to each element, creating a new list of the results:

    new_list = [f(x) for x in the_list]
    

提交回复
热议问题