Search code examples
pythondjangofor-looppasswordspassword-checker

for loop for password add letters in django


so i want to check if my password less from key_bytes (which is 16) then the password will be add "0" until it's have len 16. i was using django. for example password = katakataka. it's only 10. then it will became "katakataka000000"

i don't know how to make loop for, so please help me.

here's my code

key_bytes = 16
if len(key) <= key_bytes:
        for x in key_bytes:
            key = key + "0"
            print(key)

Solution

  • Is this what you are looking for?
    we can use range command which have a format:

    for x in range(start_count,end_count)
        key_bytes = 16
        key = "katakata"
    
        if len(key) <= key_bytes:
            for x in range(len(key),key_bytes):
                key = key + "0"
                print(key)