1

Below is my code.

l1 = "Hello World"
x1 = enumerate(l1)
print(x1)
print(type(x1))

x2 = list(x1)
x3 = list(x1)
print(x2)
print(x3)

the output of the above code is as follows:

<enumerate object at 0x000002119D35D9A8>
<class 'enumerate'>
[(0, 'H'), (1, 'e'), (2, 'l'), (3, 'l'), (4, 'o'), (5, ' '), (6, 'W'), (7, 'o'), (8, 'r'), (9, 'l'), (10, 'd')]
[]

the problem is that X3 is not having the same value as X2 is having... instead X3 becomes a blank list.

i want to know the reason as to why it is working like this.

Andrej Kesely
  • 168,389
  • 15
  • 48
  • 91

0 Answers0