Post

@PythonPr Answer: B) [1, 2, 3, 1, 2, 3]
List multiplication repeats the entire list!
› [1, 2, 3] * 2 creates [1, 2, 3, 1, 2, 3]
› Like string repetition: "ab" * 2 = "abab"
› Not element-wise multiplication
For beginners: Want [2, 4, 6]? Use [x*2 for x in a] for element-wise math!
English

@PythonPr In Python, the list * operator repeats the list instead of multiplying the elements. For example, when you type [1, 2, 3] * 2, you get [1, 2, 3, 1, 2, 3] as a result. So, the list is kind of copied.
English

@PythonPr In Python, multiplying a list by a number (e.g., a * 2) repeats the list that many times.
So, the list a = [1, 2, 3] when multiplied by 2 becomes [1, 2, 3, 1, 2, 3]. The elements are repeated, not doubled in value. So the answer is B
English

@PythonPr 1. The * operator in python when dealing with list data types, it replicates the elements inset n times provided. It doesn't perform element-wise multiplication as in other languages
2. a*2 concatenates the list object [1,2,3] itself hence a new list [1,2,3,1,2,3] in memory
English

@PythonPr B
multiplying list operation, creates new list that contains multiple times of element at multiplied list.
English

@PythonPr B — [1, 2, 3, 1, 2, 3]
Because list multiplication repeats the list, it doesn’t multiply individual elements.
English

@PythonPr a*2 does not multiply 2 elements
it repeats the list 2 times
output= [1, 2, 3, 1, 2, 3]
English





























