python之路之猜数游戏

import random #使用模块

print('welcome man')

scret=random.randrange(0,10)
cnt=0
guess=int(input('plz input suz:'))
if (guess==scret):
    print 'you get it!'
else:
    if (guess > scret):
        print 'guess more!'
    else :
        print 'guess less!'
    cnt=cnt+1
    while((guess!=scret)and(cnt<3)):
        guess=int(input('plz input suz:'))
        if (guess==scret):
            print 'you get it'
        else:
            if (guess > scret):
                print 'guess more!'
            else :
                print 'guess less!'
        cnt=cnt+1
print '-------game over!-----------'

你可能感兴趣的:(python之路之猜数游戏)