1
時寫在那裏你猜1和100之間的隨機生成的數字中的程序是一個整數或者字符串:如何檢查是否輸入了一個值使用輸入
from random import randint
play='y'
print 'Guess a number between 1 and 100'
while play=='y':
x = randint(1,100)
guess=1000
while guess != x:
guess=input('Guess: ')
if guess < x:
print 'Higher'
if guess > x:
print 'Lower'
print 'You got it! Good Job! The number was ' + str(x)
play=raw_input('Would you like to play again(y/n)?: ')
raw_input("Press <enter> to exit")
當用戶進入一個猜測,是不一個整數如何打印這不是一個數字,然後讓他們繼續猜測?