fork download
  1. # your code goes here
  2. #player picks random number
  3. #computer tries to guess
  4.  
  5. print 'Pick number between 1 and 10, including 10'
  6. import random
  7. x = random.randrange(11)
  8. print 'Is your number', x, '?'
  9. y = ''
  10. while True:
  11. if y != 'Correct':
  12. y = raw_input('Input whether your guessed number is \'Correct\', \'Higher\', \'Lower\' \n')
  13. if y == 'Lower':
  14. x -= 1
  15. x = random.randrange(0, x + 1)
  16. print 'Is your number', x, '?'
  17. elif y == 'Higher':
  18. x += 1
  19. x = random.randrange(x, 11)
  20. print 'Is your number', x, '?'
  21. elif y == 'Correct':
  22. print 'Good game'
  23. break
  24. raw_input('\n\nPress \'Enter\' to exit')
Runtime error #stdin #stdout #stderr 0.02s 10040KB
stdin
Standard input is empty
stdout
Pick number between 1 and 10, including 10
Is your number 6 ?
Input whether your guessed number is 'Correct', 'Higher', 'Lower' 
stderr
Traceback (most recent call last):
  File "prog.py", line 12, in <module>
EOFError: EOF when reading a line