N
N
Nikolai Ostrovsky2020-10-02 16:40:28
Python
Nikolai Ostrovsky, 2020-10-02 16:40:28

How to repeat actions n times?

The code
elif int(message.text.lower()) <= int('14'):
        def chapter_create(n, text):
            for _ in range(n):
                print(text)
 
        chapter_create(int(message.text), burn)

Good day! There was a problem with generating the nth number of random texts.
The burn variable should take a random string from the .txt file, but it turns out that it generates text once and duplicates it the specified number of times. Help me make it so that n times there is a different value.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IKIQ, 2020-10-03
@KotoFeyic

In the loop, right after “for ... :” you need to generate a new random line number each time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question