|
发表于 2017-5-5 13:49:48
|
显示全部楼层
本帖最后由 ButcherRabbit 于 2017-5-5 13:51 编辑
你的程序只需要改一个小小的地方,还有加载模块,最好在最前面,不要放到循环里面
我改了倒数第二行的代码,因为input()在Python3里默认是字符串类型,字符串类型,while :循环就不会成立
- import random
- startsign = 1
- while startsign == 1:
-
- number=random.randint(1,20)
- print('---------welcome to windkingland----------\n\n\nnice to meet you!\n\nlet\'s play a game !\n')
- temp=input("Do you know what the number is in my mind?\n")
- guess = int(temp)
- i = 1
- while guess != number and i<4:
- if guess > number:
- print("Nope,you are bigger!\n")
- else:
- print("Nope,you are smaller!\n")
- temp=input("please try again!\n")
- guess = int(temp)
- i = i+1
- if guess == number:
- print("you are right ,congradulations!\ngame over\n")
- else:
- print("come on!\n It's really easy.you are a boy who have a lazy brain .\ngame over\n\n\n ")
- print("DO you want to play with me again?\n1_yes 0_no")
- startsign = int(input())
- print("ok,see you next time,have a good day!\n--------------happy ending----------------")
复制代码 |
|