0

this first code im going to show you works

def spam():
 """Prints the word eggs!"""
 egg = "Eggs!"
 print (egg)
spam()

But this one does not work i don't under stand

def spam():
 """Prints the word eggs!"""
 print "Eggs!"
spam()

Turns out i was missing the brackets in the print "Eggs!" should have been print ("Eggs!")

asked Nov 17, 2015 at 20:03
4
  • 1
    You can see how your code looks like while posting. Please take a look at it while posting and format your code appropriately. I have fixed it for you, but do make sure next time you format it properly. Commented Nov 17, 2015 at 20:06
  • 2
    are you using python 3? because you need brackets around your print parameters Commented Nov 17, 2015 at 20:07
  • also, your docstring lies, it prints Eggs! not eggs! Commented Nov 17, 2015 at 20:07
  • thanks i am new and im just exploring it is my first post so "yeah" Commented Nov 17, 2015 at 20:08

1 Answer 1

1

You must be using python 3, since it requires parentheses with a print statement. Try to do:

print("Eggs!")

Instead of:

print "Eggs!"

Notice how your first function has parenthesis:

print(egg)

That's why it works.

answered Nov 17, 2015 at 20:08
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.