0

Weird output for python

#So this is my code. def answer(): answer="I will try" if answer("I will try"): return ("Good luck"); elif answer ("I won't know the result tho"): return ("At least you try"); else: return ("May God bless your efforts"); print (answer) #but my output is <function answer at 0x01295660> #why is this so?

29th Jan 2018, 5:05 PM
Ragon
2 Answers
+ 2
def answer(): answer="I will try" if answer == "I will try": return "Good luck" elif answer == "I won't know the result tho": return "At least you try" else: return "May God bless your efforts" print(answer()) When you call your function in print() you have to call answer().. you had answer without the ()... I also replaced your if statements of If answer("I will try"); with If answer == "I will try"
29th Jan 2018, 5:15 PM
LordHill
LordHill - avatar
+ 1
thanks. :) ur a good guy
29th Jan 2018, 5:25 PM
Ragon