Q. Find the Error. Consider the following code, which runs correctly at times but gives error at other times. Find the error and its reason.
Lst1 = [23, 34, 12, 77, 34, 26, 28, 93, 48, 69, 73, 23, 19, 88]
Lst2 = []
print("List1 originally is:", Lst1)
ch = int(input("Enter 1/2/3 and predict which operation was performed?"))
if ch = 1:
Lst1.append (100)
Lst2. append (100)
elif ch == 2:
print(Lst1.index(100))
print(Lst2.index(100))
elif ch == 3:
print (Lst1.pop())
print(Lst2.pop()
Answer =
Error in line 10 and 13, because Lst2 is empty list.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )