Doubt about a question I’m trying to solve I have this following code in python:

Asked

Viewed 55 times

-2

temperaturas_c = [('Argentina', 20), ('Brasil', 30), ('Estados Unidos', 28)]

I have a list that contains the names of the countries and their temperature in Celsius in a tuple, I would like to transform values in Celsius in Fahrenheit and display the same list of tuples with the country name and temperatures in Fahrenheit

1 answer

-2


To do it in a very efficient way I’ll use the function map() python in its code to get the list of tuples with the original name and temperature modified in Fahrenheit

Then I’d stay that way:

temperaturas_f = list(map(lambda temp: (temp[0], (9/5) * temp[1] + 32), temperaturas_c))
  • 1

    thank you, it worked :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.