Computer Science, asked by jana09092000, 4 months ago

Assume, you are given two lists: a = [1,2,3,4,5] b = [6,7,8,9] The task is to create a list which has all the elements of a and b in one dimension. Output: a = [1,2,3,4,5,6,7,8,9] Which of the following option would you choose?
A) a. append(b)
B) a. extend(b)
C) any of the above
D) none of these

Answers

Answered by vachharajanisuraj
3

Answer:

B

Explanation:

Option B will adjoin the elements of B after elements of A So, option B is correct

Answered by BrainlyYoda
4

a.extend(b) will be used to have all the elements of a and b in one dimension.

Extra Information

append() method in Python takes the argument and adds it as a single element at the end of the list.

extend() method in Python loops over the argument which helps us in adding each element in the list.

Let's see the question again

a = [1, 2, 3, 4, 5]

b =  [6, 7, 8, 9]

Here our argument is b =  [6, 7, 8, 9]

A) a.append(b)

If this is used then the output will be

a = [1, 2, 3, 4, 5, [6, 7, 8, 9]]

B) a.extend(b)

If this is used then the output will be

a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

Python is created by Guido van Rossum and came into existence in 1991. It is a high-level and general programming language. It is a very lucid programming language as it has a good language construct and object-oriented approach. It is dynamically typed and garbage-collected.

Similar questions