Python Forum
Indexed position editing of a lst
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Indexed position editing of a lst
#4
just use assignment
>>> my_list = ['foo', 'bar']
>>> my_list[0] = 'spam'
>>> my_list
['spam', 'bar']
>>> my_list = [1, 2, 3, 4]
>>> my_list[1:3] = [5, 6]
>>> my_list
[1, 5, 6, 4]
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Indexed position editing of a lst - by ShruthiLS - Sep-26-2019, 07:13 AM
RE: Indexed position editing of a lst - by buran - Sep-26-2019, 07:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Operations on indexed variables in loop Fibulavie 1 1,943 Aug-14-2019, 06:07 AM
Last Post: fishhook
  If you deque a list, can it still be indexed? netrate 6 10,127 Nov-07-2016, 12:19 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020