list1 = ["Me", "Jean-Pierre", "Beverley", "Philip", "Louise", "Charmaine"]
for name in list1:
if name is "Me":
print("Hello",name+", how are you?")
ok so the code itself is pretty simple and I was just messing around with lists, when I encountered a problem with it, whenever I remove my name from the list i.e "me" it also removes the entry "Jean-Pierre". I don't understand this at all?
I've tried different methods of removing my name such as
but it doesn't help. What did resolve the issue was sorting the list before the for loop using:
Can anybody explain this?