print "Pick a number between 0 and 100. I will try to guess your number." max = 101 min = 1 guess = (max-min)//2 n = ' ' print 'My guess is:' ,guess, 'is that correct?' n = raw_input("\n\nH, L or C?: ") while n != 'C': if n == 'H': max = guess min = 1 guess = (max-min)//2 + 1 print 'You said too high. How about' ,guess, '?' n = raw_input("\n\nH, L or C?: ") elif n == 'L': max = 101 min = guess guess = (max-min)//2 + min print 'You said too low. How about' ,guess, '?' n = raw_input("\n\nH, L or C?: ") while n == 'C': print "I guessed it! Thanks for playing" break
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question