Python Forum

Full Version: SyntaxError: invalid syntax at run .py
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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
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.
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
(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.
I think they want to run another file from this one
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
Run is not a command inside of python. Try just putting sales.py.
hi. it says that sales.py is not defined
(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.
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.
Pages: 1 2