chevron_left
Cookbooks
Accessing an item in a listAdding items to a listChecking if a list is emptyChecking whether a value is in a listConcatenating two listsCopying a list in PythonDifference between append and extend methodsDifference between sort and sortedFinding the index of an element in a listFinding the length of a listIterating from index oneLooping through listsModifying listsPrinting a list in reverse orderRemoving items from a listSorting a listUsing enumerate and zip at the same time
thumb_up
0
thumb_down
0
chat_bubble_outline
0
auto_stories new
settings
Modifying lists in Python
Programming
chevron_rightPython
chevron_rightOperations
chevron_rightList Operations
chevron_rightCookbooks
schedule Jul 1, 2022
Last updated local_offer Python
Tags tocTable of Contents
expand_more We can modify lists in Python using index notation or slice expressions.
Examples
Index notation
To modify the element at index position 1:
['apple', 'raspberry', 'pear']
Slice expression
To modify the first two elements:
['strawberry', 'banana', 'pear']
Join our newsletter for updates on new DS/ML comprehensive guides (spam-free)
Published by Arthur Yanagisawa
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Ask a question or leave a feedback...
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!