Simple Program with "if" statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Simple Program with "if" statement

the program stopps after the user enters an output of yes, without any error message ...the prompt runs that's it. Would you please help me understand why please ? I tried also with a while loop but it seems I made some error of str. beeing not callated. #Programm to ask about something and react to it with a standard sentence f="What do you see right now?" print(f) see=input() print("take a break") print(f) print("is your "+see+" beautifull?") answer = input() if answer == "yes": print=("Yes !") elif answer == "no": print=("may be you schould look closer") else: print=("answer not accepted")

9th Nov 2019, 12:19 PM
Layla Di
Layla Di - avatar
2 Answers
+ 1
Look closer inside your if and else statements, you wrote: print = ("Yes!") So even if print is a builtin function, it can be modified. And you just made it a string, which is why, when the loop runs again, and runs this line: print(f) print will no longer be a function to write an output, but it is now a string, thus the error "str object is not callable"
9th Nov 2019, 12:26 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
OMG you are right ! Thank you a million Aymane Boukrouh !
9th Nov 2019, 12:35 PM
Layla Di
Layla Di - avatar