小编Gab*_*dao的帖子

如何在Python中退出循环?

我想让循环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 …
Run Code Online (Sandbox Code Playgroud)

python syntax syntax-error

-1
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×1

syntax ×1

syntax-error ×1