I would like a bit of clarification here


def spam():
"""This will print 'Eggs!'"""
print "Eggs!"

Why do I have to end the code with "spam()"? What does that do and why will "Eggs!" not print without it?


When you write the code

def spam()
    print "Eggs!"

your just making a function. In this case, the functions name is spam() and all that it does is print "Eggs!" A function is just a chunk of code that can be called, but it won't just run by itself. In order to call your function and make it print "Eggs!" you write


This basically just finds the function called spam and does whatever it is that you programmed it do, in this case, it will print "Eggs!"

Let me know if you have any questions :smiley:


That makes sense, thank you!


No problem! Could you click the button on my answer that says something like "solution" or "accept answer" to show that the question has been answered? Thanks!