CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Consider a list: list1 = [6,7,8,9]
What is the difference between the following operations on list1:
a. list1 * 2
b. list1 *= 2
c. list1 = list1 * 2

Open in App
Solution

  1. The statement will print the elements of the list twice, i.e [6, 7, 8, 9, 6, 7, 8, 9]. However, list1 will not be altered.
  2. This statement will change the list1 and assign the list with repeated elements i.e [6, 7, 8, 9, 6, 7, 8, 9] to list1.
  3. This statement will also have same result as the statement 'list1 *= 2'. The list with repeated elements i.e [6, 7, 8, 9, 6, 7, 8, 9] will be assigned to list1.

flag
Suggest Corrections
thumbs-up
9
similar_icon
Similar questions
View More
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Operations on Sets
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon