ExamVeda
Login
Home
Introduction to Python
?

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

Answer & Solution
Correct Answer: Option D
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]',).
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.