Q. What will be the output of following code?


x = ['3', '2', '5']

y = " "

while x :

    y = y + x [-1]

    x = x [: len(x) -1]

print (y)

print (x)

print (type(x), type(y))



Answer =

Output:-

523
[]
<class 'list'> <class 'str'>
>>>

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. how the output of x comes an empty list

    i my view the answer will 3

    please explian it how ???

    ReplyDelete
    Replies
    1. It takes a year for me to understand of it

      Delete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post