Jump to content

A Simple python program that allows you to mess with a list


G+_Nevrin O
 Share

Recommended Posts

I wondered that myself. I guess maybe they thought pop() was easier because it does not require a parameter but they have explained parameters in previous lessons so... /shrug

One thing I think is important is that while similar, pop and remove are different and are used for different situations.

Both pop() and remove() have parameters while pop()'s is optional and is for removing something by its index in the list (if empty it removes the last item in list). remove()'s parameter on the other hand is required and it looks for the value that is contained in the list (the content as apposed to the location).

pop() also returns the value of whatever it removed while remove() just silently removes it from the list.

Oh and they both cause an error if trying to remove something that isn't there so a try/except block is highly recommended.

Link to comment
Share on other sites

 Share

×
×
  • Create New...