code breaker program in python is not working properly [closed]


code breaker program in python is not working properly [closed]


enter code here



import random



digits = list(range(10))
random.shuffle(digits)
print(digits)
my_list = [str(item) for item in digits [:3]]
print (my_list)
digits = (''.join (my_list))
print (digits)



guesses = 0
while guesses <=3:


if(guesses == 3):
break

guess = input('What is your guess ? :- ' )
tmp = ''
for i in guess:
if i.isdigit():
tmp += i
guess = tmp[:3]

print(guess)

count = 0
for i in range(3):

for j in range(3):
if digits[i] == guess[j] :
#if i == j:
count = count + 1
exit()

if count == 3 :
print('found:',end = ' ')
print('YOU WON')
exit()
break
elif ((count>0) and (count <3)) :
print('near:',end = ' ')
else:
print('nope' , end = ' ')


guesses +=1



This question appears to be off-topic. The users who voted to close gave this specific reason:





What is the error you are getting?
– Almenon
Jul 1 at 17:46




1 Answer
1



You have an exit() right after you calculate count in the nested for loops, so the program stop whenever the user enters a guess.


exit()


count


for

Popular posts from this blog

How to make file upload 'Required' in Contact Form 7?

Rothschild family

amazon EC2 - How to make wp-config.php to writable?