Friday, September 16, 2022

[FIXED] Why is this invalid syntax?

Issue

Why is this complaining about an invalid syntax?

#! /usr/bin/python

recipients = []
recipients.append('chris@elserinteractive.com')

for recip in recipients:
    print recip

I keep getting:

File "send_test_email.py", line 31
    print recip
              ^
SyntaxError: invalid syntax

Solution

If you are using Python 3 print is a function. Call it like this: print(recip).



Answered By - Nikola Smiljanić
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.