About 37,100,000 results
Open links in new tab
  1. Python - Change List Items - W3Schools

    Change a Range of Item Values. To change the value of items within a specific range, define a list with the new values, and refer to the range of index numbers where you want to insert the new …

  2. python - How to modify list entries during for loop ... - Stack Overflow

    Sep 8, 2023 · Modifying each element while iterating a list is fine, as long as you do not change add/remove elements to list. You can use list comprehension: l = ['a', ' list', 'of ', ' string '] l = …

  3. Python – Change List Item - GeeksforGeeks

    Dec 24, 2024 · Modifying elements in a list is a common task, whether we're replacing an item at a specific index, updating multiple items at once, or using conditions to modify certain …

  4. Python: Replace Item in List (6 Different Ways) - datagy

    Oct 19, 2021 · In this tutorial, you’ll learn how to use Python to replace an item or items in a list. You’l learn how to replace an item at a particular index, how to replace a particular value, how …

  5. Python: Replacing/Updating Elements in a List (with Examples)

    Jun 6, 2023 · If you want to update or replace a single element or a slice of a list by its index, you can use direct assignment with the [] operator. This is usually the simplest and fastest way to …

  6. How to edit a specific item in a list in python - Stack Overflow

    Mar 14, 2015 · list = ["60", "70", "40", "30", "73", "8"] Here for example, how would i go about taking an item out of the list (Let's say 40 for example) performing an operation on it (let's say …

  7. python modify item in list, save back in list - Stack Overflow

    A common idiom to change every element of a list looks like this: for i in range(len(L)): item = L[i] # ... compute some result based on item ... L[i] = result

  8. How to Replace an Element in a List in Python - Tutorial Kart

    Python provides multiple ways to replace elements in a list: Using Indexing: Directly assigning a new value at a specific index. Using Slicing: Replacing multiple elements at once.

  9. How to Replace Values in a List in Python – TheLinuxCode

    2 days ago · Remember that list.index() only returns the first occurrence of the value, so this approach works best for unique values. Using Slice Assignment. Python allows you to replace …

  10. Python Lists and Arrays - W3Schools

    Python Lists Access List Items Change List Items Add List Items Remove List Items Loop Lists List Comprehension Sort Lists ... List Methods. Python lists come with several built-in …

Refresh