S=['TOM', 'HARRY', 'MAMA', 'JOE']
print(S)
for x in S:
print(S.pop())
if S==[]:
print("Empty")
break
Using a for loop should iterate through the entire list and give me all the items followed by 'Empty' but instead, it only gives two elements
What I'm getting-
['TOM', 'HARRY', 'MAMA', 'JOE']
JOE
MAMA
What I was expecting-
['TOM', 'HARRY', 'MAMA', 'JOE']
JOE
MAMA
HARRY
TOM
Empty
This is my first question here so any tips on how to frame questions would be appreciated.