What am i missing?


#1



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!'


#2

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.

spam()

#3

Hi,

I still dont quite understand could you explain further


#4

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
spam().

The following works:

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

#5

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!'
spam()

Thank you so much


#6

Hello I am Mahmoud Essam from Egypt

I have a question in one of the codes excersises
Instructions
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


#7

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


#8

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


#9

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