Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Invalid syntax
#1
When i run this,


import csv

def main():
with open("battle_royale.csv") as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
print(row)

print ("Battle Royale Tournament Registration")
options = input("Please enter your option using these keys. A: find pre-registered player , B: Find player number, C: Print player lists, Q: Quit program")
if(options == "A"):
preRegist = input("Type in what player you would like to choose.")
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
for item in row:
if input == row(1)
print("You chose," + (preRegist))

print("You chose," + (preRegist))
elif(options == "B"):
playerNum = input("Type your player number.") if(options == "Q"):
print("Goodbye.")
if(options == "C"):
print("See the list of players above.")
main()

I get the error
File "main.py", line 16
if input == row(1)
^
SyntaxError: invalid syntax
Ive tried fixing the indentation, but it doesn't seem to be a indentation issue.
What am I doing wrong?

edit : added screenshot with original indentation, since it removed it when posting                
Reply
#2
if input == row(1):
Slome likes this post
Reply
#3
(May-13-2022, 08:29 PM)Axel_Erfurt Wrote: if input == row(1):

Oh I see, thanks!
Now im getting the error
File "main.py", line 17
print("You chose," + (preRegist))
^
TabError: inconsistent use of tabs and spaces in indentation
When i've only used the space bar.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  print(f"{person}:") SyntaxError: invalid syntax when running it AryaIC 11 16,377 Nov-07-2020, 10:17 AM
Last Post: snippsat
  Invalid syntax error, where? tucktuck9 2 3,433 May-03-2020, 09:40 AM
Last Post: pyzyx3qwerty
  Invalid syntax defining a dictionary? ep595 6 5,113 Nov-19-2019, 08:06 PM
Last Post: ThomasL
  Syntax Error: Invalid Syntax in a while loop sydney 1 4,086 Oct-19-2019, 01:40 AM
Last Post: jefsummers
  [split] Please help with SyntaxError: invalid syntax Mason 1 2,210 Apr-28-2019, 06:58 PM
Last Post: Yoriz
  SyntaxError: Invalid syntax in a while loop ludegrae 3 14,759 Dec-18-2018, 04:12 PM
Last Post: Larz60+
  SyntaxError: invalid syntax at run .py tuxo9999 10 7,285 Aug-23-2018, 03:58 PM
Last Post: Axel_Erfurt
  Homework: Invalid syntax using if statements chehortop 3 3,668 Mar-01-2018, 04:38 AM
Last Post: micseydel
  invalid syntax error penlemon 4 3,845 Jan-27-2018, 02:46 PM
Last Post: sparkz_alot
  Invalid syntax: string index out of range darkreaper1959 6 6,174 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