乘号 发表于 2020-2-27 10:07:08

代码报错,哪位大佬帮忙看看

import random

counts = 4
answer = random.randint(1,10)

while counts > 0:
    temp = input("猜猜我心里想的是哪个数字?(只有四次机会哦))
    guess = int(temp)

    if guess == answer:
      print("竟然猜对了…………")
      print("既然猜对了,那么给你个奖励:对着镜子石头剪刀布,没赢不许睡觉")
      break

    else:
      if guess < answer:
            print("小了哦~")
      else:
            print("大了哦~ ")
    counts = counts-1
temp = input("按0进入下一轮")
guess = int(temp)


import random

counts = 4
answer= random.randint(1, 10)

while counts > 0:
    temp = input("猜猜我心里想的是哪个数字?(只有4次机会哦)")
    guess = int(temp)

    if guess == answer:
      print(" 怎……么……又……猜……对……了……")
      print("猜对奖励:背诵弟子规10000遍")
      break

    else:
      if guess < answer:
            print("小啦~")
      else:
            print("大啦~")
    counts = counts - 1
temp = input("按0进入下一轮")
guess = int(temp)

import random

counts = 4
answer= random.randint(1, 10)

while counts > 0:
    temp = input("猜猜我心里想的是哪个数字?(只有4次机会哦)")
    guess = int(temp)

    if guess == answer:
      print(" 这,这,竟然然猜对了!")
      print("猜对奖励:给自己来一拳")
      break

    else:
      if guess < answer:
            print("小啦~")
      else:
            print("大啦~")
    counts = counts - 1
temp = input("按0进入下一轮")
guess = int(temp)


import random

counts = 4
answer= random.randint(1, 10)

while counts > 0:
    temp = input("猜猜我心里想的是哪个数字?(只有4次机会哦)")
    guess = int(temp)

    if guess == answer:
      print(" 啥?!你居然又双叒叕猜对了!")
      print("猜对奖励:给自己一个最爱吃的耳光")
      break

    else:
      if guess < answer:
            print("小啦~")
      else:
            print("大啦~")
    counts = counts - 1
temp = input("按0进入下一轮")
guess = int(temp)



import random

counts = 4
answer= random.randint(1, 10)


while counts > 0:
    temp = input("再猜猜我心里想的是哪个数字?(只有4次机会哦)")
    guess = int(temp)

    if guess == answer:
      print(" 哼!居然又猜对了!")
      print("哼,不玩了,掰掰")
      break

    else:
      if guess < answer:
            print("小啦~")
      else:
            print("大啦~")
    counts = counts - 1


temp = input("按7退出")
guess = int(temp)

if guess == 7:
    print("掰掰")



wuqramy 发表于 2020-2-27 10:09:51

。。。。。。写那么多代码干嘛,直接加个while循环不就行啦!?

qiuyouzhi 发表于 2020-2-27 10:15:14

写个循环不好吗?????
还有,导入模块一次就行了

wuqramy 发表于 2020-2-27 10:18:17

wuqramy 发表于 2020-2-27 10:09
。。。。。。写那么多代码干嘛,直接加个while循环不就行啦!?

import random

counts = 4
answer = random.randint(1,10)

while True:

    while counts > 0:
      temp = input("猜猜我心里想的是哪个数字?(只有四次机会哦)")
      guess = int(temp)

      if guess == answer:
            print("竟然猜对了…………")
            print("既然猜对了,那么给你个奖励:对着镜子石头剪刀布,没赢不许睡觉")
            break

      else:
            if guess < answer:
                print("小了哦~")
            else:
                print("大了哦~ ")
      counts = counts-1
    temp = input("按0进入下一轮,按7退出")
    guess = int(temp)
    if temp == 0:
      continue
    elif temp == 7:
        print("掰掰")
      break

乘号 发表于 2020-2-27 10:26:44

谁能帮帮我~
页: [1]
查看完整版本: 代码报错,哪位大佬帮忙看看