0

Running program in the background?

I tried making a program that tries to brute force guess a password. Its not the code I'm having trouble with but it seems python can't run a program in the background. Here is my sample code: password = 4 guess = 0 if guess == password: print("Yes") else: guess = guess + 1 It should continue until the point it gets to printing "Yes" but it just says no output.

2nd May 2018, 2:14 PM
Redd
Redd - avatar
2 Answers
+ 1
The program only checks if guess is equal to password ONCE. So use a loop to check it multiple times... password = 4 guess = 0 while guess != password: guess += 1 # same as guess = guess + 1 print("Yes")
2nd May 2018, 3:05 PM
TurtleShell
TurtleShell - avatar
+ 1
guess = '' for _ in range(4): guess = input('Enter password') if guess == password: break else: print("You didn't guess, sorry")
2nd May 2018, 5:29 PM
Amaras A
Amaras A - avatar