我正在制作倒计时游戏(游戏节目)并且无法让它发挥作用。
无效的声部用-------
分隔。
import random # Import Module_1
import time # Import Module_2
choice = 0
number = 0
z = input("How many Big Numbers?")
if int(z) == 1:
print (random.randrange(25,125,25))
elif int(z) == 2:
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
elif int(z) == 3:
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
elif int(z) == 4:
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
elif int(z) == 5:
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
elif int(z) == 6:
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
print (random.randrange(25,125,25))
x = input("How many Small Numbers")
if y == int(z) + int(x):
if int(y) >= 7:
if int(x) == 1:
print(random.randrange(0,11,1))
elif int(x) == 2:
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
elif int(x) == 3:
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
elif int(x) == 4:
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
elif int(x) == 5:
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
elif int(x) == 6:
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
print(random.randrange(0,11,1))
else:
print("That Doesn't Add up to 6 Numbers.")
答案 0 :(得分:0)
在线if y == int(z) + int(x):
变量y
未定义。请注意,==
是比较,而不是作业(=
)。另外我相信你必须使用for
循环而不是复制粘贴一行来做几次。
答案 1 :(得分:0)
如果没有if语句,应该这样做。
y = int(z) + int(x)
请注意,您使用=
来定义y
。它直接进入else语句的原因是因为没有定义y
。
如果您真的想要优化
,其余的行将如下所示if int(y) >= 7:
if int(x) <= 6:
for i in range(x):
print(random.randrange(0,11,1))