211k views
5 votes
(PYTHON & use recursion) Write a new function, countdown_evens(count), that works just like countdown, except it only prints even numbers. Example:

>>> countdown_evens(9)
8
6
4
2
Blastoff!

1 Answer

3 votes

def countdown_evens(count):

if count == 0:

print("Blast off!")

exit()

elif count % 2 == 0:

print(count)

count -= 2

else:

count -= 1

countdown_evens(count)

User Bindas
by
5.5k points