You can put all your functions in a list and call sequentially
all the functions that are contained in a slice of the list, as in this
toy example
In [11]: l_of_functions = [ lambda x=x: print(x) for x in range(10)]
In [12]: for fun in l_of_functions[5:]: fun()
5
6
7
8
9
In [13]: for fun in l_of_functions[0:]: fun()
0
1
2
3
4
5
6
7
8
9
In [14]:
Addendum
In case the OP needs a function to get a number from a closed interval, here it is my attempt
In [28]: def ask_inside(minimum, maximum, max_tries=10, this_try=0):
...: answer = input('Give me a number comprised between %d and %d: '
...: %(minimum, maximum))
...: try:
...: number = int(answer)
...: except ValueError:
...: number = minimum-1
...: if minimum <= number <= maximum: return number
...: if this_try+1<max_tries:
...: return ask(minimum, maximum,
...: max_tries=max_tries, this_try=this_try+1)
...: else: print('You are boring')
...:
In [29]: ask_inside(1, 6, max_tries=3)
Give me a number comprised between 1 and 6: 2
Out[29]: 2
In [30]: ask_inside(1, 6, max_tries=3)
Give me a number comprised between 1 and 6: ojig
Give me a number comprised between 1 and 6: 0
Give me a number comprised between 1 and 6: 7
You are boring
In [31]:
Of course if you are on Python 2 print
is a statement and input()
→ raw_input()
.