Hugh Chalmers Hugh Chalmers - 8 days ago 7
Python Question

Guess a number python issue

I'm having a problem with this script, but I see nothing wrong with it, can anyone help?

import random
selected_number=random.randint(1,100)
print('The number is between %d and %d') % (selected_number - selected_number / 5, selected_number + selected_number / 5)
def guess():
number_input=raw_input()
if number_input > selected_number:
print('Lower...')
guess()
if number_input < selected_number:
print('Higher...')
guess()
if number_input == selected_number:
print('Correct')
guess()
guess()

Answer

If you are using Python 2 :

number_input = input()

For Python 3 :

number_input = int(input())
Comments