Func | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Func

def func(level): if level==1: return 1 else: return level+func(level-1) print(func(5)) level - is argument? Can somebody explain me how it works? after ELSE what it do level+func...? thank you!

28th Oct 2018, 10:09 PM
Menashe Tsaran
Menashe Tsaran - avatar
2 Answers
+ 2
Thank you very much!
28th Oct 2018, 11:11 PM
Menashe Tsaran
Menashe Tsaran - avatar
+ 2
This type of methods are called recursive methods. Learn more here! https://www.tutorialspoint.com/data_structures_algorithms/recursion_basics.htm
31st Oct 2018, 12:03 PM
Seniru
Seniru - avatar