I was going through a tutorial about defining functions with an example on creating new lines, and the code you had to write was this:
def new_line():
print
def three_lines():
new_line()
new_line()
new_line()
def nine_lines():
three_lines()
three_lines()
three_lines()
print "hello world"
print nine_lines()
print "goodbye"
Could anybody explain why it includes ‘None’ before ‘goodbye’?
You are printing the result of calling the
nine_lines()function. Since that function does not explicitly return a value (using thereturnstatement, if you haven’t seen that yet then you will soon), Python returns the special valueNone.To fix this, change that line to simply