I was making a function that could output the results one by one with yield or return all results in a list. I have everything in the right indention, but it always. Does anyone know the reason why?
I am using Python 3.9 if that helps.
I am using Python 3.9 if that helps.
def get_ep_info(iter=False):
ep_list_info = list()
ep_nums = [1,2,3,4,5]
for ep_num in ep_nums:
if iter is True:
print("true")
yield ep_num
elif iter is False:
print("false")
ep_list_info.append(ep_num)
if iter is False:
print("false")
return ep_list_info
a = get_ep_info()
print(a)Output:<generator object get_ep_info at 0x0000022A5D048BA0>

.