For some reason when I select "run module", IDLE won't run the first line of code until I press "enter". It's not a huge problem for this type of program, but I'm confused why this is happening. Can anyone clear this up for me? Here's the code:
print("Please think a number between 0 and 100!")
guess = 50
upper = 100
lower = 0
status = ""
while status != "c":
print("Is your secret number ") + str(guess) + ("?")
print ("Lower: ") + str(lower)
print ("Upper: ") + str(upper)
status = raw_input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. ")
if status == "h":
upper = guess
guess = guess - (guess - lower)/2
elif status == "l":
lower = guess
guess = guess + (upper - guess)/2
elif status == "c":
break
else:
print("Sorry, I did not understand your input.")
print("Game over. Your secret number was: ") + str(guess)
Thanks so much!
See http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/execution.html (see section 1.9.2). It's a bug that occurs sometimes if the previous program was interrupted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With