uaveiro-leci/1ano/1semestre/fp/aula03/ex12.py

17 lines
338 B
Python
Raw Permalink Normal View History

2022-10-11 19:27:51 +00:00
def main():
num = int(input('De onde vai começar o contador? '))
2022-10-18 17:18:56 +00:00
for n in countdown(num):
print(n)
2022-10-11 19:27:51 +00:00
# Creates a range() function with the format range(n:0:-1)
# The statement yield returns a value every repetition
2022-10-11 19:27:51 +00:00
def countdown(n):
2022-10-18 17:18:56 +00:00
while n > 0:
yield n
n -= 1
2022-10-11 19:27:51 +00:00
2022-10-18 17:18:56 +00:00
if __name__ == "__main__":
main()