How to change elements in a list?

Опубликовано: 30 Сентябрь 2024
на канале: CyberTodd
1,115
44

You can change any item inside a list, by targeting the index and assign the new value. Example:

list = ['First Value', 'Second Value', 'Third Value']
list[0] = 'New Value'
print(list)

Output:
list = ['New Value', 'Second Value', 'Third Value']

-------------------------Subscribe----------------------------
• If you like to see a variety of fun and interactive projects written in Python
• If you love ☕ and 🐶 WAIT! - Yeah! Definitely, coffee and dogs!
-----------------------------------------------------------------------

-------------------------Socials----------------------------
• Twitter:   / iftodd1  
• Facebook:   / iftodd  
• Instagram:   / if_todd  
------------------------------------------------------------------

-------------------------Support----------------------------
You can support me here:   / if_todd  
--------------------------------------------------------------------

How to change elements in a list? #Python #shorts