DEV Community

Discussion on: 50 Python Interview Questions and Answers

Collapse
 
renegadecoder94 profile image
Jeremy Grifski

Can you expand a bit on question 2? If I were to convert a list into a tuple, I would probably throw the list right at the tuple constructor:

>>> my_list = [1, 2, 3]
>>> my_tuple = tuple(my_list)
>>> my_tuple
(1, 2, 3)
Enter fullscreen mode Exit fullscreen mode

The answer provided seems to be answering a different question.

Collapse
 
muhimen123 profile image
Muhimen

I agree with that. I run the code, and this is the result.

>>> print(my_tuple)
(50, 'Eighty', 9)

But the real answer should be something like this:

(50, 'Twenty', 110, 'Fifty', 'Ten', 20, 10, 80, 'Eighty')