Answer the question
In order to leave comments, you need to log in
How to call a function n times, where n is given by the user?
The program reads one given formula in which the user enters two values measured in the lab. The number of measurements is different for each, but the formula is always the same. Communication with the program through the console. Is it possible to make it so that when starting the program it asks for the number of measurements?
Answer the question
In order to leave comments, you need to log in
how_many_times_run_func = int(input("Please enter how many timw you wont run formula: "))
input
use it instead raw_input
class FormulaRunner:
def ask_user_run_times():
try:
how_many_times_run_func = int(input("Please enter how many timw you wont run formula: "))
return how_many_times_run_func
except ValueError:
print("Ooops value must be a number")
return FormulaRunner.ask_user_run_times()
def my_super_formula():
print("toster.ru")
if __name__ == "__main__":
run_times = FormulaRunner.ask_user_run_times()
for _ in range(run_times):
FormulaRunner.my_super_formula()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question