I want to take a function and repeat it by an amount which a user will input. Thanks in advance!

Recommended Answers

Use for loop with range.

Jump to Post

All 2 Replies

Use for loop with range.

Like Tony recommends:

def ten_times(n):
    print(n*10)

x = int(input("How many repeats (enter an integer value): "))

for n in range(x):
    ten_times(n+1)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.