G+_Nevrin O Posted April 12, 2014 Share Posted April 12, 2014 A Simple python program that allows you to mess with a list. add, remove, sort, etc. there are more commands I could add but I thought this will do for now. https://github.com/NevrinO/Coding/blob/master/Python/Lists/List%20ITD.py Link to comment Share on other sites More sharing options...
G+_L I Posted April 14, 2014 Share Posted April 14, 2014 makes you wonder why they introduced list.pop() instead of list.remove() Link to comment Share on other sites More sharing options...
G+_Nevrin O Posted April 14, 2014 Author Share Posted April 14, 2014 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 More sharing options...
Recommended Posts