Summing and multiplying
Lists can be added and multiplied in the same way as strings. "insert" FUNCTION
insert method is similar to append, except that it allows you to insert a new item at any position in the list, as opposed to just at the end. "range" FUNCTION
* The range function creates a sequential list of numbers. *If range is called with one argument, it produces an object with values from 0 to that argument. If it is called with two arguments, it produces values from the first to the second. *range can have a third argument, which determines the interval of the sequence produced ALL & ANY
Often used in conditional statements, all and any take a list as an argument, and return True if all or any (respectively) of their arguments evaluate to True (and False otherwise). |
IN and NOT operator
The in operator is also used to determine whether or not a string is a substring of another string. "index" FUNCTION
index method finds the first occurrence of a list item and returns its index. List comprehensions
Trying to create a list in a very extensive range will result in a MemoryError. ENUMERATE
The function enumerate can be used to iterate through the values and indices of a list simultaneously. |
"append" FUNCTION
This adds an item to the end of an existing list. "Len" FUNCTION
List slicing 1
Basic list slicing involves indexing a list with two colon-separated integers. List slicing 2
List slices can also have a third number, representing the step, to include only alternate values in the slice. |
Cheatography
https://cheatography.com
Python3 Lists: Everything you need to know Cheat Sheet by nimakarimian
Python3 List Operations and functions
Created By
https://www.nimakarimian.ir
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
More Cheat Sheets by nimakarimian