-3

I'm trying to do a nested if statement

for x in listsent:
    print(x)
    
    z = input()
    if z == 1:
        tag = "O"
        q = input()
        if q == 1:
            pos = "Q"
        elif q == 2:

            

    elif z == 2:
        tag = "Q"
        q = input()
        if q == 1:
            pos = "O"
        elif q == 2:

but when when I enter 1 in the first IF statement it takes me to the next item in the for loop instead of taking me to the second if statement

khelwood
  • 55,782
  • 14
  • 81
  • 108
M Mela
  • 55
  • 1
  • 6
  • 3
    `input()` returns a string, not an int – khelwood Jul 10 '20 at 08:24
  • 2
    Spend the time to learn how to use a debugger, and step through your code line by line, and watch what your variables are doing at each stage. You will find it altogether easier to find and solve problems with your code once you know how to do this. – Jack Aidley Jul 10 '20 at 08:26
  • Is this your real code? It looks invalid because there is nothing following the `elif q == 2:` – quamrana Jul 10 '20 at 08:27

1 Answers1

1

Input returns a string, not an integer. To convert string to integer, use z = int(input()) and q = int(input()) wherever required