I was reading 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 couldn't understand why these brackets were being used for the print commands and so I removed 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 those brackets I am getting the exact same results, so I am not sure which one is correct or whether I should use those brackets at all. Is it really necessary to use those brackets?
One more thing.
when I use the brackets then the +person+ gives
the result as Happy Birthday, dear Andre.
but when I use ,person, then it gives
the result as <'Happy Birthday,dear ',' 'Andre','.'>
I am unable to understand these differences in the results. Could you shed some light on this?