V
V
Vladislav Mukhin2021-02-21 13:17:03
Python
Vladislav Mukhin, 2021-02-21 13:17:03

Why does it output the same values ​​when choosing a random value from the list again?

@Client.command()
async def ra(ctx):
    d = 0
    f = ""
    t = ""
    r = 12
    dd = 0
    rr = 5
    while dd < rr:
        while d < r:
            l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','y','w','x','y','z']
            y = random.choice(l)
            f = f + y
            y = ""
            d = d + 1
        z = "рандом: " + f + "\n"
        t = t + z
        dd = dd + 1
    await ctx.send(t)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-02-21
@SoreMix

Because the text from the variable fwas created once in the loop while d < r:and that's it. Well, then you simply duplicate this line "random: asdasd\n" in the while dd < rr:
ps loop:

from string import ascii_lowercase
print(ascii_lowercase)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question