Untitled
unknown
plain_text
2 years ago
640 B
11
Indexable
# lab1
def fibbo(n):
if(n<=1):
if(n==0):
return 0
return n
else:
return fibbo(n-1)+fibbo(n-2)
n = int(input("Enter the value of n : "))
print(f"Fibbonacci of {n} is {fibbo(n)}")
# lab2
def inside_sum(item):
sum = 0
for element in item:
if type(element) is list:
print("Worked")
sum+=inside_sum(element)
else:
sum+=element
return sum
set = [1,2,3,[[1,2,3],1,2,3]]
print(f"Sum is {inside_sum(set)}")
# lab3
def middle(list):
new_list = list[1:-1]
return new_list
list = [0,1,2,3,4]
print(f"New List : {middle(list)}")
Editor is loading...
Leave a Comment