Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
What is it all about. What is the purpose of this program. I would write like this:
numbers = [number for number in range(1, 7)]
def main():
for number in numbers:
print(number)
if __name__ == "__main__":
main()
How to make a function return all elements?
numbers = [number for number in range(1, 7)]
def numbers_generator(numbers):
for number in numbers:
yield number
def main():
for number in numbers_generator(numbers):
print(number + 1)
if __name__ == "__main__":
main()
Because the exit from the function occurs at the first returned return with the value that first got there.
Learn materiel. Read carefully.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question