Run Lines of Code Multiple Times

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
Cash Fulton
Messages
24
Reaction score
1
In Python 3...

I have a few lines of code that I want the user to choose how many times it will run. For example:

times=int(input())

'times' will be the number of times the lines of code will run.

How do I do it?
 
Physics news on Phys.org
Cash Fulton said:
Thanks for the response. Though, I don't fully understand how I would write it for my exact purpose.

Could you give me an example with the 'for loop' for what I'm trying to accomplish?
Python:
times=int(input())
myrange=range(0,times)
for count in myrange:
    yourFirstLineOfCode
    yourSecondLineOfCode
    yourThirdLineOfCode
    youGetTheIdea
print("Code has been executed the requested number of times")