?
What will be the output of the following Python code?
What will be the output of the following Python code?
x = [[0], [1]]
print((' '.join(list(map(str, x))),))
x = [[0], [1]]
print((' '.join(list(map(str, x))),))
Answer & Solution
Correct Answer:
Option
D
In the given code, the variable
The
Then,
The
Finally, the result is enclosed in a tuple using
Therefore, the output will be: ('[0] [1]',).
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]',).
Join the Discussion
Login to post a comment or share your explanation.
Login