I read about python functions and saw this code:
def happyBirthday(person):
print("Happy Birthday to you!")
print("Happy Birthday to you!")
print("Happy Birthday, dear " + person + ".")
print("Happy Birthday to you!")
happyBirthday('Emily')
happyBirthday('Andre')
I could not understand why these brackets are used for print commands, and so I deleted them.
def happyBirthday(person):
print "Happy Birthday to you!"
print "Happy Birthday to you!"
print "Happy Birthday, dear " + person + "."
print "Happy Birthday to you!")
happyBirthday('Emily')
happyBirthday('Andre')
Even after removing these brackets, I get exactly the same results, so I'm not sure which one is correct or should I use these brackets at all. Is it really necessary to use these brackets?
One more thing. when I use brackets then +person+it gives a result like happy birthday, dear Andre. but when I use ,person,, then it gives a result like "Happy Birthday, dear", "Andre", "." >
I cannot understand these differences in results. Could you shed some light on this?
faraz source
share