+ 2
Is it possible to call a function from within the same function?
Hi, is it possible to do some sort of code like this in Python? def func1() x = input ("some random input") if x == "something": #[some code] else: func1()
5 Answers
+ 3
Yes, it's called recursion.
https://www.python-course.eu/recursive_functions.php
+ 1
thanks
+ 1
Yes it most definately is.
What i tend to do is i tend to make it a yes or no option. Or if there are errors going on i return to the same function.
For example with your code,
If there was a error in 'func1()' i would make it print there is a error and then call the same function again to make it restart.
Hope this helps :)
+ 1
thanks