- Print fibonacci number using recursion.
def fib(x):
if x == 0 or x == 1:
return x
else:
return (fib(x-1) + fib(x-2))
for i in range(10):
print(fib(i))
if x == 0 or x == 1:
return x
else:
return (fib(x-1) + fib(x-2))
for i in range(10):
print(fib(i))
- Print the char and number of occurrences in a given input string.
input = "aaabbccbcc" map = {} for c in input: if(c in map): map[c] += 1 else: map[c]=1print(map) output = "" for key,val in map.items(): st = key+str(val) output += stprint(output)
More questions will be added soon!
No comments:
Post a Comment