We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 856fff5 commit f4550faCopy full SHA for f4550fa
print_recursively.py
@@ -0,0 +1,23 @@
1
+def print_recursively(lst):
2
+ """ Print items in the list, using recursion.
3
+
4
+ >>> print_recursively([1, 2, 3])
5
+ 1
6
+ 2
7
+ 3
8
+ """
9
10
+ if not lst:
11
+ return
12
13
+ print lst[0]
14
15
+ print_recursively(lst[1:])
16
17
18
+if __name__ == '__main__':
19
+ import doctest
20
+ results = doctest.testmod()
21
22
+ if results.failed == 0:
23
+ print "ALL TESTS PASSED"
0 commit comments