Break for loop in an if statement
You'll need to break out of each loop separately, as people have mentioned in the comments for your question, break
only stops the loop which it's in
for x in userpassword[k]: for z in lowercaselist: if x in z: newpasswordlist.append(z) k +=1 break if x in z: # added an extra condition to exit the main loop break
You'll need to do this for both loops
If you want to break out of the while loop as well, then you can add if x in z: break
in that loop as well.