Vidyalelo
Python · Q146

Python Lists MCQs: Exam Practice for List Concepts

Programming · Python · question 146

Q146

What will be the output of the following Python code snippet? my_string = "hello world" k = [(i.upper(), len(i)) for i in my_string] print(k)

A.
[('HELLO', 5), ('WORLD', 5)]
B.
[('H', 1), ('E', 1), ('L', 1), ('L', 1), ('O', 1), (' ', 1), ('W', 1), ('O', 1), ('R', 1), ('L', 1), ('D', 1)]
Answer
C.
[('HELLO WORLD', 11)]
D.
none of the mentioned

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board