For loop Python:用于循环中断问题

For loop Python:用于循环中断问题,for-loop,conditional,break,For Loop,Conditional,Break,我使用的是for循环,在for循环中有两个if语句,它们在for循环的每次迭代中都被检查。我的问题是,一旦其中一条if语句=True,我希望停止检查True if语句,只检查第二条if语句。反之亦然 print("Guess the numbers it is! Your goal is to guess a two digit number from 00-99. The two digits may be the same.") numGuessesN = int(input("How ma

我使用的是for循环,在for循环中有两个if语句,它们在for循环的每次迭代中都被检查。我的问题是,一旦其中一条if语句=True,我希望停止检查True if语句,只检查第二条if语句。反之亦然

print("Guess the numbers it is! Your goal is to guess a two digit number from 00-99. The two digits may be the same.")
numGuessesN = int(input("How many guesses would you like? (2, 3, or 4) "))

for numGuessesN in range (firstGuess, numGuessesN + 1) :
    print("Guess number", numGuessesN)
    userGuessN = int(input("What is your guess? "))



    if (userGuessN == randomNum1) :
        print("You've guessed the first number!") 
        break
    else :
        print("The first number is not", userGuessN)

    if (userGuessN == randomNum2) :
        print("You've guessed the second number!")
        break
    else :
        print("The second number is not", userGuessN)
我知道if语句中的中断将完全退出for循环,这不是我想要的。但不知何故,我需要for循环“中断”每个单独的语句,如果它证明该语句为真,则继续检查其余语句,直到它为真,否则循环将耗尽迭代次数


谢谢大家!我对这一切都不熟悉,所以如果我不太清楚,我很抱歉哈哈。

要么使用嵌套的if语句,要么(如果有很多,那么会有很多重复代码)设置一个变量

first_wrong=False
if bla:
    pass
else:
    first_wrong=True

if bla2 and not first_wrong:
    pass
if bla3 and not first_wrong:
    pass

要么使用嵌套的if语句,要么(如果有很多,那么就会有很多重复的代码)设置一个变量

first_wrong=False
if bla:
    pass
else:
    first_wrong=True

if bla2 and not first_wrong:
    pass
if bla3 and not first_wrong:
    pass