निम्नलिखित पायथन प्रोग्राम का आउटपुट क्या होगा?
What will be the output of the following Python program ?
def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))
A)
B)
C)
D)
Explanation:
The code adds 1
to the list mylist
by using +=
inside the addItem
function. After calling addItem(mylist)
, the list becomes [1, 2, 3, 4, 1]
. The length of the updated list is 5
.
Answer: (A) 5