#Create a function that takes in a temperature in Fahrenheit and returns the same temp in Celcius
13 messages · Page 1 of 1 (latest)
you cant access variable celsius because there isnt any
in fahrenToCelc you created Celsius variable (case sensitive) but even then it wont work because Celsius is in local scope: it only exists inside the function, once function stops execution, its destroyed and the value cant be restored
what i would do is:
- make
fahrenToCelctake an argument that is a value of temperature in fahrenheit and return the same amount in celsius withreturnkeyword - remove
from math import *, you arent using anymath's functions - remove
float(...)from the formula (line 5), you already converted fahrenheit value into float - get rid of
mainfunction, the code is light enough to not use it. plus you're executing code globally so there is no point
I havent leared return yet
so what would I do?
this is what I am left with
are you required to use a function?
yeah
then if i were you, i'd replace line 4 with line 11