jeudi 12 novembre 2020

If Else Statement Doesn't Return the Else Statement

    reject_numberList = ['1', '2', '3', '4', '5', '6']
resend_numberList = ['2', '3', '4', '5', '6', '7']

for i in range(6):
    try:
        print("Is",reject_numberList[i], "resend?")
        if(reject_numberList[i] < resend_numberList[i] and resend_numberList[i] == reject_numberList[i+1]):
            print(True)
        else:
            print(False)
    except IndexError:
        pass

Here is my code. There are some numbers rejected and resent. But number 6 doesn't return 'False'. And Here is the output:

Is 1 resend?
True
Is 2 resend?
True
Is 3 resend?
True
Is 4 resend?
True
Is 5 resend?
True
Is 6 resend?

Process finished with exit code 0

What is wrong with number 6?

Aucun commentaire:

Enregistrer un commentaire