Python Forum
SyntaxError: invalid syntax at run .py - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: SyntaxError: invalid syntax at run .py (/thread-12388.html)

Pages: 1 2


SyntaxError: invalid syntax at run .py - tuxo9999 - Aug-22-2018

Hello,

when i run this program it is giving me problems.

the sales.py right now it is only print ("sales"), but later on i am planning in changing it.

x = 0
number = 1
while number <= 10:
    suma = number + x
    number = number + 1
    print (number)
    run sales.py
it gives me this problem:
File "<ipython-input-14-b2edac43ebda>", line 7
run sales.py
^
SyntaxError: invalid syntax

thank you for your helm


RE: SyntaxError: invalid syntax at run .py - Mekire - Aug-22-2018

run sales.py should not be part of the code. Sounds like an instruction to run it that wasn't meant to be included. Get rid of that line and it should run.


RE: SyntaxError: invalid syntax at run .py - tuxo9999 - Aug-22-2018

hi,
now run sales.py it only does a print, but on the future it will do another thing, and i will have the same problem


RE: SyntaxError: invalid syntax at run .py - Mekire - Aug-22-2018

(Aug-22-2018, 03:01 PM)tuxo9999 Wrote: but on the future it will do another thing, and i will have the same problem
I don't follow. You can't have non-python code in a python file (unless it is commented out). run sales.py is not python code; thus the syntax error.


RE: SyntaxError: invalid syntax at run .py - buran - Aug-22-2018

I think they want to run another file from this one


RE: SyntaxError: invalid syntax at run .py - tuxo9999 - Aug-22-2018

i don´t understand why i can not run it because if i just write run sales.py it runs correctly, it´s when i put it in the while when it does not work


RE: SyntaxError: invalid syntax at run .py - Anysja - Aug-22-2018

Run is not a command inside of python. Try just putting sales.py.


RE: SyntaxError: invalid syntax at run .py - tuxo9999 - Aug-22-2018

hi. it says that sales.py is not defined


RE: SyntaxError: invalid syntax at run .py - nilamo - Aug-22-2018

(Aug-22-2018, 03:14 PM)tuxo9999 Wrote: i don´t understand why i can not run it because if i just write run sales.py it runs correctly, it´s when i put it in the while when it does not work

If you just put run sales.py, as you say, then it will still give an error. run doesn't mean anything in python, and will be an error always.

If you have some code that works without the while loop, please share it. It sounds like you're confusing python and shell scripts, and trying to mix them together into an unholy perl-like abomination.


RE: SyntaxError: invalid syntax at run .py - Anysja - Aug-23-2018

Quote:hi. it says that sales.py is not defined

Did you create a python document called sales.py? If you did you also need to import it or your program won't be able to communicate with it.