Python List Methods

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Adds an item to the end of the list.

list.append(x)

Returns the number of times x appears in the list.

list.count(x)

Extends a list by appending all the items in the given list

list.extend(L)

Returns the index position of the first item in the list whose value is x.

list.index(x)

Inserts an item at a given position. The first argument tells the program which index position it should put the item in front of.

list.insert(i, x)

Removes the item at the given position in the list and returns it. If no index is specified, "a.pop()" removes and returns the last item in the list.

list.pop([i])

Removes the first item from the list whose value is x.

list.remove(x)

Reverses the elements of the list, in place.

list.reverse()

sorts the items of the list in place

list.sort

the elements of s[i:j:k] are replaced by those of t

s[i:j:k] = t

slice of s from i to j is replaced by the contents of the iterable t

s[i:j] = t

removes the elements of s[i:j:k] from the list

del s[i:j:k]


Ensembles d'études connexes

And Then There Were None Chapters 1-7

View Set

Chapter 5: Operating Systems, 2223 MIS Intro to computers exam 2, Chapter 9, Introduction to Computers Final Exam, CIS Ch.7, MIS Chapter 1, MIS Test 4- know acronyms, Computers Module 12, module 11 quizzes, Module 9 and 10

View Set

Business Math Ch 14: Cost of Installment Buying

View Set

Chapter 7: Suitability and Investment Risks UNIT EXAM

View Set

Preterite, Imperfect, and Demonstrative Adjectives

View Set

Pharma Module 4: PrepU Quiz & Chapter 8 Terms (Quiz Completed on Sept.22, Chapter 8: Anti-Infective Agents)

View Set

PROPERTY INSURANCE- (ICAP-Property-IV)

View Set