+ 1
Question about python âwhileâ command
Help!!! So Iâm trying to use the def and while in the following code. The idea of using âwhileâ is that the person can keep imputing the color. But for some reason, it only works for the first input. Please help! ###Let's play a game: guess my favorite color. please input color and if you give up, input "give up".### def myfav(color): if color == "red": print (color + " is my favorite color") else: print ("not my fav") while True: x=input ("color name: ") if x == "give up": print ("My fav color is red.") break else: print (x) myfav (x)
8 RĂ©ponses
+ 1
Are you running the code on Sololearn?
+ 1
Yang Yang Sololearn will ask for input only once. Multiple inputs are seperated by a new line if I remember correctly. Sublime text doesnât support input.
0
yes. does Sololearn only allow input once? Sublime on my mac doesnât run âinputâ at all. Any advice, please? Thank you! Goodester
0
Yang Yang Well that could be the problem. Try to run it on some other place.
0
Goodester I see. Thank you! Which one do you recommend, if not Sublime?
0
Yang Yang If you were asking for a good IDE/text editor, Iâd recommend PyCharm for sure.
0
Goodester thank you!!
0
Yang Yang Youâre welcome :)