I wanted to replace string with an integer so I first tried this
timeupseats=[0,480,480,0]
for n in range(0,4):
if timeupseats[n]==0:
timeupseats[n]='CLOSED'
for n in range(0,4):
if timeupseats[n]=='CLOSED':
timeupseats[n]==0
Because the first code didn't work, I tried this code for the second time and it worked
timeupseats=[0,480,480,0]
for n in range(0,4): #print closed when there is no ticket left
if timeupseats[n]==0:
timeupseats[n]='CLOSED'
timeupseats = [0 if i=='CLOSED' else i for i in timeupseats]
What's the difference between the first code and the second code? Why did only the second code work?