If a is [1, 2, 3], what is the difference (if any) between a*3 and [a, a, a]?
Answers
Answered by
14
Given a=[1, 2, 3]
The difference is that a*3 repeats the elements of the list 3 times in the given order as a whole and encloses them into the given iterable, i.e., list.
While [a, a, a] is nothing but the enclosing of iterables, i.e., lists a - as it is - into a new list.
a*3 = [1, 2, 3, 1, 2, 3, 1, 2, 3]
[a, a, a] = [ [1, 2, 3], [1, 2, 3], [1, 2, 3] ]
Learn more:
What is list comprehension python?
brainly.in/question/6964716
brainly.in/question/16086791
Difference between tuple and list.
brainly.in/question/13319756
Similar questions
English,
4 months ago
India Languages,
4 months ago
Hindi,
4 months ago
Math,
9 months ago
Math,
1 year ago
Accountancy,
1 year ago