Function junction section question


#1


I'm currently in Function Junction part and i have tried multiple times on the belwo code and eventually i got pass with the below code:-

ef spam():
    """Below command tells the machine to print the string egg"""
print "Eggs!"

However i do not understand why I got a pass? why "print eggs" code can pass without without any indent?

Please help thanks!


#2

You just printed "Eggs!", but your function does nothing, if you call your function it won't do anything, if you want your function to print you need to indent your pirnt


#3

di you unsderstand it?


#4

since the print is on a separate line in the editor its not part of the def spam() function. It just a print command to the console. Hope that helps


#5

Can you please help me here!!!

What have i don wrong


#6

def spam():
eggs = "You are an egg"
return eggs

print spam()


#7

i have tried
it still does not work


#8

what lesson is this in. what number ?


#9

Based on your screenshot there is no : after def spam(). you need to enter that
def spam():


#10

Lesson 2.Function Junction

I tried again and I get this....


#11

the issue is with your spacing. Python is very sensitive about white space so you have to mindful of that


#12

And you are not following Instructions which are on the left side toward the bottom. :wink:


#13

def spam():
"""Prints 'Hello World!' to the console."""
o =("Eggs!")
print o


#14

Define your spam function starting on line 5. You

can leave the code on line 11 alone for now--we'll

explain it soon!

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

Define the spam function above this line.

spam()


#15

Define your spam function starting on line 5. You

can leave the code on line 11 alone for now--we'll

explain it soon!

def spam():
print "Eggs!"
"""This is a comment"""

Define the spam function above this line.

spam()

-here an a example answer,it works for me-