adplus-dvertising
frame-decoration

Question

What is the output of the following code?
a="hello"
b=list((x.upper(),len(x)) for x in a)
print(b)

a.

[(‘H’, 1), (‘E’, 1), (‘L’, 1), (‘L’, 1), (‘O’, 1)].

b.

[(‘HELLO’, 5)].

c.

[(‘H’, 5), (‘E’, 5), (‘L’, 5), (‘L’, 5), (‘O’, 5)].

d.

Syntax error

Posted under Lists in Python Python

Answer: (a).[(‘H’, 1), (‘E’, 1), (‘L’, 1), (‘L’, 1), (‘O’, 1)].

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the following code?