mercredi 24 juin 2020

what's wrong with my if-statement? not the result i wanted

please help me, why my condition shows the output directly while the condition is still not met? this is my code:

def s(text, order):
    length = len(order)
    count, count_size = len(text), length
    words = [text[i:i+count_size]for i in range (0, count, count_size)]

    for i in range(len(words)):
        if len(words[i]) < length:
            words[i] += '_'

    return words

print(s("just for testing",[4,7,2,8,3,1,0,9,6,5]))

this is the output

['just for t', 'esting_']

I think the output will show results like this

['just for t', 'esting____']

Aucun commentaire:

Enregistrer un commentaire