W
W
WolfInChains2020-06-14 20:49:17
Python
WolfInChains, 2020-06-14 20:49:17

How to execute a function multiple times?

It is necessary that this function be executed a certain number of times (the user himself enters) and the number is written to the array. How can I do that?

def number():
    for number in chek:
        new_el = number.split(':')
        num = random.randint(int(new_el[0]), int(new_el[1]))
    return num

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2020-06-14
@WolfInChains

?
Or stop, in what array?

results = []
iterations = int(input())
for _ in range(iterations):
    result = number()
    results.append(result)

S
ScriptKiddo, 2020-06-14
@ScriptKiddo

result = [number() for _ in range(10)]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question