CBSE Class 11 Computer Science Question 70 of 104

List Manipulation — Question 6

Back to all questions
6
Question

Question 6

What will the following code result in?

L1 = [1, 3, 5, 7, 9]
print (L1 == L1.reverse( ) )
print (L1)

Answer

Output
False
[9, 7, 5, 3, 1]
Explanation

L1 is not equal to its reverse so L1 == L1.reverse( ) gives False but L1.reverse( ) reverses L1 in place so after that statement executes, L1 becomes [9, 7, 5, 3, 1].

Answer