Python Forum
SyntaxError: invalid syntax at run .py
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError: invalid syntax at run .py
#1
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
Reply
#2
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.
Reply
#3
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
Reply
#4
(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.
Reply
#5
I think they want to run another file from this one
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
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
Reply
#7
Run is not a command inside of python. Try just putting sales.py.
Reply
#8
hi. it says that sales.py is not defined
Reply
#9
(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.
Reply
#10
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Invalid syntax Slome 2 1,910 May-13-2022, 08:31 PM
Last Post: Slome
  print(f"{person}:") SyntaxError: invalid syntax when running it AryaIC 11 16,096 Nov-07-2020, 10:17 AM
Last Post: snippsat
  Invalid syntax error, where? tucktuck9 2 3,378 May-03-2020, 09:40 AM
Last Post: pyzyx3qwerty
  Invalid syntax defining a dictionary? ep595 6 5,020 Nov-19-2019, 08:06 PM
Last Post: ThomasL
  Syntax Error: Invalid Syntax in a while loop sydney 1 4,027 Oct-19-2019, 01:40 AM
Last Post: jefsummers
  [split] Please help with SyntaxError: invalid syntax Mason 1 2,145 Apr-28-2019, 06:58 PM
Last Post: Yoriz
  SyntaxError: Invalid syntax in a while loop ludegrae 3 14,612 Dec-18-2018, 04:12 PM
Last Post: Larz60+
  Homework: Invalid syntax using if statements chehortop 3 3,597 Mar-01-2018, 04:38 AM
Last Post: micseydel
  invalid syntax error penlemon 4 3,776 Jan-27-2018, 02:46 PM
Last Post: sparkz_alot
  Invalid syntax: string index out of range darkreaper1959 6 6,096 Jan-22-2017, 06:24 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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