mirror of
https://github.com/DavidGailleton/42-Piscine_Python.git
synced 2026-01-27 01:01:59 +00:00
piscine 00
This commit is contained in:
6
00/ex5/ft_count_harvest_iterative.py
Normal file
6
00/ex5/ft_count_harvest_iterative.py
Normal file
@@ -0,0 +1,6 @@
|
||||
def ft_count_harvest_iterative():
|
||||
print("Days until harvest:", end=" ")
|
||||
i = range(1, int(input()) + 1)
|
||||
for n in i:
|
||||
print("Day", n)
|
||||
print("Harvest time!")
|
||||
9
00/ex5/ft_count_harvest_recursive.py
Normal file
9
00/ex5/ft_count_harvest_recursive.py
Normal file
@@ -0,0 +1,9 @@
|
||||
def ft_count_harvest_recursive(x=-1):
|
||||
if x < 0:
|
||||
print("Days until harvest:", end=" ")
|
||||
x = int(input())
|
||||
ft_count_harvest_recursive(x)
|
||||
print("Harvest time!")
|
||||
elif x > 0:
|
||||
ft_count_harvest_recursive(x - 1)
|
||||
print("Day", x)
|
||||
Reference in New Issue
Block a user