Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Python code?
l=list(‘HELLO’)
‘first={0[0]}, third={0[2]}’.format(l)

What will be the output of the following Python code?
l=list(‘HELLO’)
‘first={0[0]}, third={0[2]}’.format(l)
a) ‘first=H, third=L’
b) ‘first=0, third=2’
c) Error
d) ‘first=0, third=L’

Answer: a
Explanation: In the code shown above, the value for first is substituted by l[0], that is H and the value for third is substituted by l[2], that is L. Hence the output of the code shown above is: ‘first=H, third=L’. The list l= [‘H’, ‘E’, ‘L’, ‘L’, ‘O’].

Join The Discussion