0

If I have a list like:

a = [1,2,3,4,5] 

And I delete the first element:

del(a[0])  

How many assignments occurs? Does one assignment only occur when your e.g. set a[1] = 7? Or can you say that 4 assignments occur in the background since every element in the list gets a new index?

Laangas
  • 1
  • 2
  • 1
    Do not name python lists `list`, as it overrides a builtin name. – user3483203 Apr 10 '18 at 14:00
  • Deleting elements is an O(n) average case operation: https://wiki.python.org/moin/TimeComplexity – user3483203 Apr 10 '18 at 14:01
  • Welcome to Stack Overflow! I don't think it's worth editing your question again, but for future reference - we put the language in the tags (and generally avoid putting the language in the title) : https://stackoverflow.com/help/tagging – PaulG Apr 10 '18 at 17:00

0 Answers0