Help with def statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help with def statement?

I need some serious help understanding the syntax of 'def', when to use it, and why you would use it instead of something possibly simpler? Also more specifically, how it works and how the syntax of the statement ties in to the output.

5th May 2018, 3:51 AM
<code>Love</code>
1 Answer
+ 4
I use it for separate pieces of code that I think I can reuse in other codes. For instance I have a function to find all divisors of a number. I can use it to do exactly that. But I can also use it to find primes. Because it are numbers with only two divisors.
5th May 2018, 5:17 AM
Paul
Paul - avatar