0

I'm trying example listed in How do I connect to a MySQL Database in Python?

When I try to execute the program in Python 3.0 GUI I receive error for last print statement

for x in range(0,numrows):
row = cursor.fetchone()
print row[0], "-->", row[1] 

Error is Invalid Syntax for row[0]

Any Pointers would be helpful.

Thanks, Siva

Community
  • 1
  • 1
Siva
  • 2,791
  • 5
  • 29
  • 33

1 Answers1

4

in python3 print is a function, so it's print(row[0]+"-->"+row[1])

Uku Loskit
  • 40,868
  • 9
  • 92
  • 93
  • But you can also do `print(row[0], "-->", row[1])` rather than the string concatenation. – Keith May 26 '11 at 00:39