Python Programming - Variables - Discussion
Discussion Forum : Variables - General Questions (Q.No. 19)
19.
What is the output of the following code:
my_list = [1, 2, 3]
my_list[1] = 4
print(my_list)
Answer: Option
Explanation:
In this code, the variable my_list
is initially assigned a list containing the values 1, 2, and 3.
The second element of the list (which has an index of 1) is then changed to 4 using the assignment operator =
.
When my_list
is printed to the console, it shows the modified list [1, 4, 3]
.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers