diff --git a/num_ways.py b/num_ways.py new file mode 100644 index 0000000..6f76771 --- /dev/null +++ b/num_ways.py @@ -0,0 +1,11 @@ +print("How many stairs would you like to climb? ") +x=input() + +def fibonacci_number(N): + if N<=1: + return N + return fibonacci_number(N-1) + fibonacci_number(N-2) + + +def num_ways(N): + return fibonacci_number(N+1) diff --git a/replace.py b/replace.py new file mode 100644 index 0000000..0701105 --- /dev/null +++ b/replace.py @@ -0,0 +1,14 @@ +def replace(listt, find, replace): + list2=list(listt) + for i, value in enumerate(list2): + if listt[i] == find: + listt[i] = replace + + elif type(value) in[list, tuple]: + list2[i]=replace(list2[i], find, replace) + + return list2 + +exampleList = [ 'a', 1, [ ['a', 'b'], 1], ([1, 3, 'a'], 'b')] +res = replace(exampleList, 'a', 'c') +print(res)