< Kurs:Python < Material < Scripts
Countdown
Scripts
Lösung mit Rekursion
def countdown(n):
if n == 0:
print "- - -!"
else:
print n
countdown(n-1)
Lösung mit Iteration
def countdown(n):
while n > 0:
print n
n = n-1
print "- - -"
This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.