diff --git a/homeworks/19_Lachezar_Lazarov/num_ways.py b/homeworks/19_Lachezar_Lazarov/num_ways.py new file mode 100644 index 0000000..12b0479 --- /dev/null +++ b/homeworks/19_Lachezar_Lazarov/num_ways.py @@ -0,0 +1,9 @@ +M = input("Stairs to climb: ") + +def num_ways(n): + if n == 0 or n == 1: + return 1 + else: + return num_ways(n-1) + num_ways(n-2) + +print(num_ways(int(M))) diff --git a/homeworks/19_Lachezar_Lazarov/replace1.py b/homeworks/19_Lachezar_Lazarov/replace1.py new file mode 100644 index 0000000..00a32a2 --- /dev/null +++ b/homeworks/19_Lachezar_Lazarov/replace1.py @@ -0,0 +1,14 @@ +def replace1(list1, find, replace): + for i in range(0, len(list1)): + if list1[i] == find: + list1[i] = replace + try: + if len(list1[i]) > 1: + list1[i] = replace1(list1[i], find, replace) + except: + continue + return list1 + +list1 = [ 'a', 1, [ ['a', 'b'], 1], ([1, 3, 'a'], 'b')] +res = replace1(list1, 'a', 'c') +print(res) # => [ 'c', 1, [ ['c', 'b'], 1], ([1, 3, 'c'], 'b')]