Characters being repeated in String discovery [Python]

0

The purpose here is to find out the passwords, in the same trial and error, and it's all going well while the letters, but when they arrive in the numbers, they repeat for a reason that I do not really understand . If someone can find the error in the code, I'm grateful.

import random
senha='TasLAVa4554'
alfa='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
num='123456789'
def breakK(x):
    ans=''
    for y in senha:        
        for z in alfa:
            if str(y)==str(z):
                print('Verificando aspectos...')
                ans+=str(z.upper())
            if str(y)==str(z.lower()):
                print('Verificando aspectos...')
                ans+=str(z.lower())
            else:
                print('Testando...')
                for n in num:
                    if str(y)==str(n):
                        print('Verificando aspectos')
                        ans+=str(n)
                    else:
                        print('Verificando aspectos')

    print(ans)
####
print(breakK(senha))    
    
asked by anonymous 23.12.2017 / 20:12

1 answer

0

Notice the loops. The first iterates over each character of the password, the second over each alpha character. This has an if with an else and in that else you iterate over num. This means that every time you enter the else, which repeats for each alpha character, it will test num. The for n in num: must be at the same level as for z in alfa:

    
23.12.2017 / 21:19