PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, September 16, 2022

[FIXED] Why is this invalid syntax?

 September 16, 2022     printing, python, python-3.x, syntax-error     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

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

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing