Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to exit 2 loops
#4
for maybe in answer:

for correct in sequence:

^ i dont think this is right. youre checking each place against each right answer. i think you want this:

check if digit 0 matches answer 0
check if digit 1 matches answer 1
check if digit 2 matches answer 2
check if digit 3 matches answer 3
check if digit 4 matches answer 4

and i think what youre doing with two loops is this:

check if digit 0 matches answer 0
check if digit 0 matches answer 1
check if digit 0 matches answer 2
check if digit 0 matches answer 3
check if digit 0 matches answer 4

check if digit 1 matches answer 0
check if digit 1 matches answer 1
check if digit 1 matches answer 2...

i think you have one loop too many.

you want a single loop (i think) and a check on both sequence and answer with the same loop index.

something like this?

        for dex in range(5):
            maybe = answer[dex]
            correct = sequence[dex]
Reply


Messages In This Thread
How to exit 2 loops - by Midnight1810 - Dec-09-2017, 05:38 PM
RE: How to exit 2 loops - by buran - Dec-09-2017, 05:41 PM
RE: How to exit 2 loops - by Midnight1810 - Dec-09-2017, 06:25 PM
RE: How to exit 2 loops - by ezdev - Dec-09-2017, 08:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python difference between sys.exit and exit() mg24 1 1,878 Nov-12-2022, 01:37 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020