1 / 5

Lists in Python

Lists in Python. List methods and functions. List methods. Notes about methods. These methods, append, sort, reverse, all change the original list. If you need to retain the original list as well as keep the resulting list, use sorted( listname ) and list(reversed( listname ))

garima
Télécharger la présentation

Lists in Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lists in Python List methods and functions

  2. List methods

  3. Notes about methods • These methods, append, sort, reverse, all change the original list. • If you need to retain the original list as well as keep the resulting list, use sorted(listname) and list(reversed(listname)) • Just as with strings, index will cause an exception and program crash if its search fails

  4. List functions

  5. Notes about functions and methods • When the previous two tables say “items must be comparable”, it means they must all be of numeric type, or they must all be strings. Mixing them will cause an exception and crash • When they say “in place” it means that it will change the original list. • For the sum function, items can be integer or float

More Related