Computer Science, asked by kumarg965415pabgsk, 6 months ago

If a is [1, 2, 3], what is the difference (if any) between a*3 and [a, a, a]? ​

Answers

Answered by poojan
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
Physics, 6 months ago