# -*- coding: cp936 -*- import random n = 0 m = 0 i = random.randint(1,100) #print i print"猜数字游戏开始了:" print"一共有六次机会,猜一个1-100的数字" while m < 6 and n != i: n = input("请输入一个1-100的数字") if n == i: print "恭喜你猜对了" break elif n > i: print "大了" else: print "小了" m = m + 1 else: print "六次你都没有猜中!"
原文地址:http://lmdtx.blog.51cto.com/6942028/1610593