Answers for assignment 4
1 Answer
list1=[5,10,15,20,25,50,20]
if 20 in list1:
index=list1.index(20)
list1[index]=200
print(list1)
else:
print("value not found in list1")
[5, 10, 15, 200, 25, 50, 20]
2 Answer
list1=[5,20,15,20,25,50,20]
ele=20
x=[i for i in list1 if i !=ele]
print(x)
[5, 15, 25, 50]
3 Answer
list1=[10,20,30,40]
list2=[100,200,300,400]
list2.reverse()
print(list2)
for (a,b) in zip(list1,list2):
print(a,b)
[400, 300, 200, 100] 10 400 20 300 30 200 40 100