Deleting items from a List

# Deleting items from a List

##### Lesson Details:
September 17, 2020

Video Transcription: In this yet another electron less we people are going to see how to delete the items in a list this video is brought to you by Appy Pie’s Academy, so we will learn let me give the comment we will learn how to delete items in a list so what I am going to do is first I am going to create a list with the name book underscore codes and I'm going to give some hypothetical values suppose 1 double 0 1 comma 2 double 0 9 comma 8 double 0 7 comma 7 double 0 5 then comma 5 triple 6 comma 4 triple 9 okay so these are the values of the list now I I will print all the items by writing print book underscore codes and as you are aware that the same thing could have been accomplished by writing I am writing it in comments or we could have written it like this print book underscore codes and : right this is just to revise the things okay so now I'm going to use this method del I would write del book underscore codes I have used this command l then I would write del book under score codes within square brackets I am writing to now what does it mean it means the item at index number two would be deleted so the item at index number two is a double zero seven it will be deleted so in order to illustrate this I would be printing this statement again print book underscore codes so that we can see that eight the item at index number two has been removed okay click right click on the program name then go to run okay so here is the output okay so you can see first it is printing the whole list and in the second output it is displaying the list without the value a double zero seven because it has been deleted okay now I would write del book I would tell you how to delete a range of values so del book underscore codes and let me write for example now we are left with five items only or new there were six items now we are left with five items because we have deleted one item so now I am going to write del book underscore codes to suppose it's an example just an example to : 5 now what does it be it means starting from index number 2 till index number 4 the items will be deleted so I will get it printed on the screen I will get the list printed on the screen so that we can see that these items have been removed so it's a kind of range starting from index number 2 till index number four not five four so yeah you can see so starting from index number two that was seven double zero five and till four triple nine all these three values they were removed and when I printed the list it printed only two items which were left in the list okay right so far so good now we will learn how to delete the whole list I want to delete all the items of the list so in order to do this you would write del and simply give the name of the list that's it so and after that I will print this list book underscore quotes let's see the output so right click on the program go to run and yes as you can see no output is being shown and the compiler is showing an also book underscore codes is not defined actually this error is very much valid because we have deleted the whole list.