Why is this complaining about an invalid syntax?
#! /usr/bin/python
recipients = []
recipients.append('[email protected]')
for recip in recipients:
print recip
I keep getting:
File "send_test_email.py", line 31
print recip
^
SyntaxError: invalid syntax
If you are using Python 3 print is a function. Call it like this: print(recip).
In python 3, print is no longer a statement, but a function.
Old: print "The answer is", 2*2
New: print("The answer is", 2*2)
More python 3 print functionality:
Old: print x, # Trailing comma suppresses newline
New: print(x, end=" ") # Appends a space instead of a newline
Old: print # Prints a newline
New: print() # You must call the function!
Old: print >>sys.stderr, "fatal error"
New: print("fatal error", file=sys.stderr)
Old: print (x, y) # prints repr((x, y))
New: print((x, y)) # Not the same as print(x, y)!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With