0
votes

I am making a small program using a while loop to convert Fahrenheit to Celsius by taking the temps from a list and sending it to a function for calculation. Once it converts the temp from F to C it will print the result for each temp. I am not looking to have the code written for me, I am just looking for some information to get me in the right direction. This is what I have so far, but I don't think that I need the for loop in it. temp is supposed to be each temperature in Fahrenheit and the add function is supposed to convert it to Celsius.

def add(x):
    return float(x - 32) * 5.0/9.0


temp = [-10, -2, 7, 16, 24, 32, 41, 50, 58, 67, 75]
while True:
    for x in temp:

        print(x)
1

1 Answers

2
votes

You don't need the while True loop. And you don't want to print the items in temp; you want to print the result of calling add() on each item in temp.

for x in temp:
    print(add(x))