Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
'return' is used in a function to return the result of the function call. e.g.: def add(a, b): return (a+b) print (add(3, 5)) 'yield' is used in generators. A Python generator is a function that produces a sequence of results, which can be iterated. e.g. of a generator : def myrange(n): for i in range(n): yield i for x in myrange(10): print (x)
18th Oct 2019, 11:02 PM
Loïc Mahé
Loïc Mahé - avatar