Found a bug while using 'del' statement. Must be a little mistake; i just can't figure it out

Bug description:

Expected vs Current Behavior:

Steps to reproduce:

Bug appears at this link:

Screenshot(s)/Screen Recording:

Browser/OS/Device: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Replit Profile:

This isn’t a bug. It looks like you’re trying to delete item 0 and item 1 (the first two items). So let’s put it in perspective:

This is the guest list:

['Betty the Orchid', 'Rose']

And you call:

del guest_list[0]

The list is now:


And then you call:

del guest_list[1]

But since you deleted the first item earlier, and now there is only one item, then guest_list[1] doesn’t exist. So basically, you just need to change the:

del guest_list[1]


del guest_list[0]

Your code would look like this now:

print(guest_list[1], "You have officially been invited to the 2- seated dinner table :) See you at 6:30 PM!")
del guest_list[0]
del guest_list[0]

So this is not a bug, it was just that your second object was non-existent since you deleted the first one and the second became the first.


Hi, @ParisaYakubova1!

Could we please have more information, such as any errors or unexpected behavior?

Misread some stuff, changed the topic to Python

1 Like

Oh alright! Thank you so much for clarifying that for me! Appreciate it :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.