[Solved] How to update particular elements in a list? [closed]


If you write all the statements in the same line, it will be an invalid syntax.

For this, solution 1:

a=['vishal',123,345,'out',25,'going']
a[2]=455 
a[0]='dinesh'

Now print your list, you will see the result:

['dinesh', 123, 455, 'out', 25, 'going']

If you don’t want to write in different lines, you can do this,
Solution 2:

a=['vishal', 123, 345, 'out', 25, 'going']; a[2] =455; a[0]='dinesh'

Use semi-colon between the statements, this makes the code run correctly.

0

solved How to update particular elements in a list? [closed]