关闭。这个问题需要debugging details .它目前不接受答案。
想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。
5年前关闭。
Improve this question
我想让循环在 x + y =z
时停止,另外。
代码:
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 16 18:39:40 2015
@author: gabri
"""
from random import randint
import os
x = randint(1,11)
y = randint(1,11)
print ("", x,"+", y,"=\n")
z = int(input("Resposta="))
if z == x + y:
input ("\n\nCorreto\nPrima enter para continuar...")
else:
for z in range(0, 10):
os.system('CLS')
input ("Incorreto.\n\n Tente de novo...")
x = randint(1,11)
y = randint(1,11)
os.system('CLS')
print ("", x,"+", y,"=\n")
z = int(input("Resposta="))
if z == x + y:
input ("\n\nCorreto\nPrima enter para continuar...")
exit
最佳答案
替换 exit
与 break
. Exit
不是在 Python 中退出循环的方法。
break statement docs
关于python - 如何在 Python 中退出循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33742912/