How to Modify Lists Using Phyton

by zcy in Living > Education

223 Views, 0 Favorites, 0 Comments

How to Modify Lists Using Phyton

Screen Shot 2022-10-11 at 2.52.34 PM.png

This instruction set is for beginners using Phyton. There are 5 basic modifications to a list using phyton, but this instruction set only includes how to make and name a list, add items, index, update and remove items in the list. To learn more about other modifications, look up more modifications to a list! 

Supplies

Materials: Phyton IDLE application

Open Phyton IDLE Shell

Screen Shot 2022-10-18 at 12.04.52 AM.png

Open the application

Name a List by Typing a Name for a Category of Your Own Choice

Screen Shot 2022-10-18 at 12.05.26 AM.png

Note: In the example above, the chosen category is colors 

Add an Equal Sign Next to It

Screen Shot 2022-10-18 at 12.06.09 AM.png

Next to the Equal Sign, Add Items to a List by Typing ‘[‘ + the Items You Want in the List Divided by ‘,’ and Close It With ‘]’ , Hit Enter

Screen Shot 2022-10-18 at 12.06.49 AM.png

Note: In the example above, the items in the list above are strings (words) which is why it needs a quotation mark but if it is numbers, it does not need any. 

Test Run the Code Using Print + Parenthesis With the Name of Your List and Hit Enter. This Is to Make Sure Your List Works Before Moving Forward!

Screen Shot 2022-10-18 at 12.07.28 AM.png

Access Values in the List by Typing Print + (name of List[number of Value You Want to Access])

Screen Shot 2022-10-18 at 12.08.05 AM.png

Hit Enter

Screen Shot 2022-10-18 at 12.08.29 AM.png

Type the Name of List+[number of Value You Want to Access] + Equal Sign

Screen Shot 2022-10-18 at 12.09.07 AM.png

Type a Word You Want to Replace the Item You Indexed With in Quotation Marks to Update an Item

Screen Shot 2022-10-18 at 12.09.35 AM.png

Hit Enter

Type Print+name of List to See the Updated List

Screen Shot 2022-10-18 at 12.10.48 AM.png

Type Name of List + Period + Remove

Screen Shot 2022-10-18 at 12.11.12 AM.png

Type the Word You Want to Remove That Is in the List in Quotation Marks Next to the Word Remove to Remove an Item

Screen Shot 2022-10-18 at 12.11.40 AM.png

Hit Enter

Check Updated Modified List by Typing Print+name of List Inside a Parenthesis

Hit Enter

Screen Shot 2022-10-18 at 12.12.25 AM.png

Congrats!