Editing lists and other content

Im fairly new to coding and I have a question. Why would we write extra code such as .insert() or .pop() or using indexing to change the content of a list? Why not just go back and edit the list itsself?
For example if I wanted to add milk to my list why not just do it where I first created a list?
Thank you!

If you were running a program which had an empty list [], and a program designed to ask the user what they wanted added to the list, and then add it, you wouldn’t be there while the program was running to manually add anything to the list, so you’d need to use code like .append in order to make the program work.

I hope this helps!

2 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.