A single break will stop the current for loop. It will not break all the other loops.
If the current for loop is nested, it will continue the parent loop and continue looping with the next iterated value in parent loop.
You will either have to add the password checking condition in each loop and break or why don't you just return?
def find_password_brute_force(password):
for i in range(0, 10):
for x in range(0, 10):
for y in range(0, 10):
for w in range(0, 10):
a = str(i) + str(x) + str(y) + str(w)
# print(a)
if a == password:
print("Your password is: " + a)
return a
password = '1567'
find_password_brute_force(password=password)
PS:
Using such code for nefarious purposes could land you in trouble -- don't do it.
I have shared it only for your understanding.