What am i missing?


I cant seem to get this right . Please help understand what i am missing

7. Functions 2 - Function Junction

The error i get is " Oops, try again. Make sure your function prints "Eggs!" to the console!"

I expected it to print Eggs

# Define your spam function starting on line 5. You
# can leave the code on line 11 alone for now--we'll
# explain it soon!

# Define the spam function above this line.
def spam(): 
    """Prints 'Eggs!' to the console."""
    print 'Eggs!'


Hi @datasolver72908 ,

Call the function so that it performs its job. The following statement will cause it to execute. Make sure the statement is not indented, since it should reside outside the function.




I still dont quite understand could you explain further


You wrote
print 'Eggs!'
with in a function named spam() .
So, It won't get printed unless you call the function.
Call the function using

The following works:

def spam(): 
    """Prints 'Eggs!' to the console."""
    print 'Eggs!'


Thanks for your quick response 90215

I did that before and the problem i had was my indent of spam() at the end. I had it like this

def spam():
"""Prints 'Eggs!' to the console."""
print 'Eggs!'

Thank you so much


Hello I am Mahmoud Essam from Egypt

I have a question in one of the codes excersises
First, def a function, shut_down, that takes one argument s. Don't forget the parentheses or the colon!
Then, if the shut_down function receives an s equal to "yes", it should return "Shutting down"
Alternatively, elif s is equal to "no", then the function should return "Shutdown aborted".
Finally, if shut_down gets anything other than those inputs, the function should return "Sorry"

I wrote:
def shut_down(message):
print shut_down

if shut_down("yes") == "yes":
result ("yes")
return"Shutting down"

the error appearing
"File "python", line 6
SyntaxError: 'return' outside function"

What is an outside function


Please don't hijack question threads with your own question.


It means you didn't indent your return statement the right way.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.