Function Junction


Replace this line with your code.

Go ahead and create a function, spam, that prints the string "Eggs!" to the console. Don't forget to include a comment of your own choosing (enclose it in triple quotes!).

Why does print have to have a space . If i place print directly under def it comes out wrong.
Can some please explain please. Does this have to do with what was taught earlier whitespaces?


Yup, it sure does.
Since Python doesn't use curly braces for holding functions and such (except for dictionaries), it uses whitespace. This shows and tells Python that anything indented under your function and/or if/elif/else statements, is what belongs to it and what is executed when called. Does this help?


it is indentation since there is a colon


So in other words not command can go under def
is that pretty much it?
Thanks for the help


Do you mean the not operator? Yes, if it's going to be in something (like a operation, or statement and such). You cant write not by itself, it won't work and it will throw an error.

Check these links out on whitespace/indentation:


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