Examveda

What will be the output of the following Python code?
x = [[0], [1]]
print((' '.join(list(map(str, x))),))

A. 01

B. [0] [1]

C. ('01')

D. ('[0] [1]',)

Answer: Option D

Solution (By Examveda Team)

In the given code, the variable x is assigned a list containing two sublists: [[0], [1]].
The map() function is used to apply the str() function to each element of x, converting them to strings.
Then, list() is used to convert the resulting map object to a list.
The join() function concatenates these strings with a space separator.
Finally, the result is enclosed in a tuple using (...) and printed.
Therefore, the output will be: ('[0] [1]',).

This Question Belongs to Python Program >> Introduction To Python

Join The Discussion

Related Questions on Introduction to Python