Python Forum

Full Version: Function Execution Times
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
If we want that any Python Function should work only once or twice then how can be done the same?
Thanks
run once or twice.
Please explain a bit better and receive a better answer.
import random

def any_python_function(something):
    print(something)


once_or_twice = random.choice((1,2))

for times in range(once_or_twice):
    any_python_function(once_or_twice)
I want to execute the program in in two parts

first;
We input the password from user and store aside.

second ;
We again input password to give them access if first input password matches with second.

Thanks