Knowee
Questions
Features
Study Tools

Write the output? A = [1,2,3] B = [4,5] A.append(B) print(len(A))

Question

Write the output? A = [1,2,3] B = [4,5] A.append(B) print(len(A))

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output will be 4.

Here's the step by step explanation:

  1. We have two lists, A = [1,2,3] and B = [4,5].
  2. The append() function in Python adds its argument as a single element to the end of a list. The length of the list increases by one.
  3. So, when we do A.append(B), it adds the list B as a single element at the end of list A. Now, A = [1,2,3,[4,5]].
  4. When we print(len(A)), it returns the number of elements in the list A, which is 4 in this case.

This problem has been solved

Similar Questions

Write the output?import numpy as np a = np.array( [1 ,2 , 3])b = np.append(a , [4, 5, 6])print( b, len(b) )

what is the output of the following code?b = [1, 2, 3]for a in b:       b.append(a)print(b)

What will be the output of the below code?list1  = [1, 2, 3]list1.append([4, 5, 6])print(len(list1))Select one:3456

What will the output of the following code be?l = [32, 34, 12, 27, 33]l.append([14, 19])print(len(l))

What do these lines print?>>> a = [1, 2, 3, 4]>>> a.append(5)>>> len(a)

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.