+ 3
Can I iterate or loop through the values of a function in Python like for i in function Name: statement
Possibility of looping through a def function using for loop
4 Respuestas
+ 2
Yes with generator. Like this
def gen(n):
for i in range(n):
yield i
for i in gen(6):
print(i)
+ 1
Yes, when the function returns an iterable (e.g. list, tuple, set, dictionary, generator, string)
+ 1
Sayed🇧🇩🇧🇩 thanks
+ 1
Benjamin Jürgens thanks
exactly. Those are the types am trying to iterate