this might be a very simple mistake but i dont know where my mistake is. i have this code, i'm trying to remove a slot from the array as the user already choose a slot. but it doesn't work. can anyone help?
slot = ['8 AM', '9 AM', '10 AM', '11 AM' , '12 AM' , '2 PM', '3 PM', '4 PM']
print "slot available:" , slot
print 'Choose your slot'
slotchoose = raw_input ("choose:")
if slotchoose == '8 AM' :
slot.remove ( '8 AM ' )
else :
if slotchoose == '9 AM' :
slot.remove ( '9 AM' )
else :
if slotchoose == '10 AM' :
slot.remove ('10 AM')
else :
if slotchoose == '11 AM':
slot.remove ('11 AM')
else:
if slotchoose == '12 AM':
slot.remove ('12 AM')
else :
if slotchoose == '2 PM' :
slot.remove ('2 PM')
else :
if slotchoose == '3 PM':
slot.remove ('3 PM')
else :
if slotchoose == '4 PM' :
slot.remove ('4 PM')
print "Slot aavail :" , slot
here is sample of the output :
slot available: ['8 AM', '9 AM', '10 AM', '11 AM', '12 AM', '2 PM', '3 PM', '4 PM']
Choose your slot
choose:8 AM
Slot aavail : ['8 AM', '9 AM', '10 AM', '11 AM', '12 AM', '2 PM', '3 PM', '4 PM']
the "8 AM" shouldn't be there
elif?elifwould be better than a lot ofif elseif slotchoose in (some valid values): slot.remove(slotchoose)?