#Point Calc System
from random import randint
team1 = 0
team2 = 0
winloss = 0
check = 0
x = 0
i = 0
#while x < 6: - Didnt work, probably formatting issue -
#x += 1
#Runs best of 3 games
while i < 3:
i = i + 1
#2 = win // 1 = loss
winloss = randint(1,2)
check = check + winloss
print("Check = ",check)
if winloss == 2:
team1 = team1 + 2
print("win ",team1)
else:
team2 = team2 + 2
print("loss ",team2)
#Test to see if a Team won 2/3 battles or won 2 in a row.
if team1 > team2 and check == 5:
team1 = team1 + 2
print("team1 wins",team1)
elif team1 > team2 and check == 6:
print("Team1 wins no add",team1)
elif team2 > team1 and check == 4:
team2 = team2 + 2
print("team2 wins",team2)
elif team2 > team1 and check == 3:
print("Team2 wins no add",team2)
else:
#Should never be seen.
print("error")
我原以为在顶部添加另一个while循环会起作用,但事实并非如此,添加了一个简单的:whilex<;6:x+=1。。。没用。你知道吗
很可能是缩进错误。你知道吗
如果在代码前面有空格的终端中运行Python
这个执行没有问题
也就是说,在去掉不正确的空格之后,下面的代码执行起来没有任何问题。你知道吗
注意:还要记住不要混合制表符和空格(在while循环或if/else语句的缩进中)
相关问题 更多 >
编程相关推荐