Nov-23-2020, 03:01 PM
Hello,
I would like to create function primes(), but when I return values from the first loop function stops.
Instead of return I try using yield, but it seems that I should make some additional code to it, because it outputs hexa code.
Greetings,
V.
I would like to create function primes(), but when I return values from the first loop function stops.
Instead of return I try using yield, but it seems that I should make some additional code to it, because it outputs hexa code.
def primes(to_number = 5): #### define new list with range to_number + 1 new_list = [] for x in range(to_number + 1): for y in range(to_number + 1): new_list.append(y) yield new_list*When I use return it's all good, but I have something more to say.. in this code:)
return [0, 1, 2, 3, 4, 5]
yield <generator object primes at 0x00000298F858F7B0>So question is, how to yield result without stopping the function?
Greetings,
V.