Python Forum
Question re: running code in Editor (i.e. Atom) vs Python interpreter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question re: running code in Editor (i.e. Atom) vs Python interpreter

New coder


Write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit, and print out the converted temperature.


When I attempted to solve the following problem in the interpreter, it results in the following:

ctemp = input('Enter Celsius Temperature') \
... ftemp = float(ctemp) * (9 / 5) + 32 \
File "<stdin>", line 2
ftemp = float(ctemp) * (9 / 5) + 32 \
SyntaxError: invalid syntax

However, when I enter the same code in the Atom editor, no error occurs and the program runs with the correct answer.

My understanding is that aside from the pro's vs con's between using an editor vs. the interpreter, the Python rules (including syntax) are the same between an editor such as Atom and the interpreter.

Can you please examine my code to explain what I've missed?

Thank you everyone in advance for your help.
Why do you have backslashes at the end of your lines? They look like complete lines, so I'm not sure what you're trying to accomplish with them.

Running a program in the interactive prompt that asks for input can be tricky. Because the input will run immediately and ask you for input, and it can be hard to tell if it's time to type an input answer, or if you're still entering code. At first, you might try it without the input and just put in a number. Then add the input back later when everything is working or you're not in the interactive prompt.
I put the backslash so that it will not execute immediately.

Thank you for your help bowlofred.

This was my first post here in the forums. Going forward I will be sure to utilize the python tags.

Any additional input is appreciated.

Thank you everyone. This forum is great!
I think the backslashes are interfering with what you're trying to do.

I'd recommend that you type it out into a file with an editor, then run the full program separately. It also helps when you're asking questions about it because everyone is certain exactly what the program is.

Possibly Related Threads…
Thread Author Replies Views Last Post
  rtmidi problem after running the code x times philipbergwerf 1 155 Apr-04-2021, 07:07 PM
Last Post: philipbergwerf
  Running a few lines of code as soon as my timer ends nethatar 3 279 Feb-26-2021, 01:02 PM
Last Post: jefsummers
  Assistance with running a few lines of code at an EXACT time nethatar 5 362 Feb-24-2021, 10:43 PM
Last Post: nilamo
  Newbie question about running Python via GUI on OSX ejwjohn 8 454 Feb-05-2021, 03:20 PM
Last Post: Larz60+
  "SyntaxError: invalid syntax" running code in Doing Math With Python b saucerdesigner 2 372 Nov-03-2020, 04:23 PM
Last Post: saucerdesigner
  Running code online aqua_ed 1 269 Oct-29-2020, 03:04 AM
Last Post: Larz60+
  Class function is not running at all even though it is clearly run in the code SheeppOSU 2 448 Sep-26-2020, 10:54 PM
Last Post: SheeppOSU
  python interpreter won't import packages greenpy 1 345 Sep-11-2020, 07:47 PM
Last Post: buran
  How could i change the python interpreter path of os.system() 12019202386 2 452 Sep-02-2020, 06:58 AM
Last Post: DeaD_EyE
  New in Python. Have question on my code. ztx19981023 2 462 Sep-02-2020, 03:34 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020