need help, newbie in town. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: need help, newbie in town. (/thread-9028.html) |
need help, newbie in town. - fburgos - Mar-18-2018 Ok I need help. I can't find the issue with this code >>> def main(): celsius=eval(input("What's the Celsius temperature" )) fahrenheit=9/5*celsius+32 print("The fahrenheit temperature is "fahrenheit) This is a simple converter, I'm just practicing around by reading a guide that I have. But for some reason I get a syntax error message when I 'print' Fahrenheit(the last line). Can someone explain me why? what am I doing wrong? RE: need help, newbie in town. - Larz60+ - Mar-18-2018 >>> indicates that you are using a command line interpreter. You must type (or paste) lines one at a time (with eol) in this mode, keeping proper indentation: In addition, you do not need nor want the eval statement you wan integer conversion instead ending up with: >>> def main(): ... celsius = int(input("What's the Celsius temperature ")) ... fahrenheit = (9 / 5) * celsius + 32 ... print("The fahrenheit temperature is {}".format(fahrenheit)) ... >>> main() What's the Celsius temperature 25 The fahrenheit temperature is 77.0 >>> |