List, List Methods & List Comprehensions

preview_player
Показать описание
A list is one of the in-built data collection type (Data Structure) available in python.

CHARACTERISTICS: Indexed, Ordered, Mutable(Changeable)

LIST METHODS / ATTRIBUTES
.extend()
Add Elements of a List to Another List

.insert()
Inserts Element to The List

.remove()
Removes item from the list

.index()
returns the first encounter or smallest index of element in list

.count()
returns occurrences of element in a list

.pop()
Removes element at the given index

.reverse()
Reverses a List

.sort()
sorts elements of a list

.copy()
Returns Shallow Copy of a List

.clear()
Removes all Items from the List

LIST COMPREHENSION
A list comprehension is an in-built, syntactic & concise way for creating a list based on an existing on an existing data collection type or array.
Рекомендации по теме
Комментарии
Автор

Can you show how to use .insert inside of a list comprehension?

niflag