Need help with a variable

import random
state = 1
balance = random.randint(500,2500)
print (balance)
 
accounts= {
 "swindrunner" : "1234",
 "istormrage" : "abcd",
 "tpgallywix" : "qwerty"
}
print (state)

while state == 1:
 print (state)
 
 userpass = ["swindrunner1234", "istormrageabcd", "tpgallywixqwerty"]
 username = input("Username:")
 password = input("Password: ")
 #AccountInfo = username + password
 print(userpass)

 break

AccountInfo = username + password
state = 2

print(state)

while state == 2:
 print(state)
 print(AccountInfo)

 if AccountInfo == "swindrunner1234" or AccountInfo == "istormrageabcd" or AccountInfo == "tpgallywixqwerty":
  print ("ok")
  state = 3
 else:
  print ("no")
  state = 1
 break
 
print(state)

while state == 3:
 input("Display, Withdraw, Deposit, Exit")

How come when the AccountInfo variable is not equal to one of the 3 correct ones, it doesn’t prompt the user to enter another username and password? It should set the state back to = 1, which should prompt the user to re-enter them to try again. So why does it just end the code?

Your code is not looping as I assume you are intending it to do.

It will make the structure of your code easier to read if you use 4 spaces of indent.

This never loops.

These checks are not part of the loop that inputs the data.

If state is 3 then this will loop asking for input forever and never do anything with it.

So how would I put it in a loop to fix it?

You indent ALL the code you want in the loop.
For example

while a:
      while b:
           while c:
               # etc

White space indentation is how python knows what statements are grouped together.