Skip to playerSkip to main contentSkip to footer
  • 5/17/2025
Lists are mutable and dynamic; list items can be added, removed or changed after the list is defined. Lists are ordered; newly added items will be placed at the end of the list. Lists use zero-based indexing; every list item has an associated index, and the first item's index is 0. Duplicated list items are allowed.

Category

📚
Learning
Transcript
00:00Welcome back, so now let's talk about list methods, let's define a new list, let's call
00:09this numbers, and in this list of numbers, let's say numbers, 1,2,3,4,5,6,7,8,9, okay,
00:20now if I want to count, then I can count and call this and value, now I want to count
00:32the value of the method which I want to give you, it will be the list of numbers.
00:38For example, I want to count the number one, and I want to count this one, so if I print
00:44it, print, okay, and I execute it, and you guess it, one, let's check nine,
00:56I execute it, and no change, let's put another nine, and now check, and kaboom, shaka,
01:06lackah, now you say that two times you have, you have to give me the item, you have
01:11two times appear, interesting, okay, now what if, if I want this now, location,
01:20and I want to count the index, then this method simple is index, and if I give this index
01:29If we give this element, we will give you the index of the first appearance of the location.
01:34For example, we will run this.
01:35This is the eighth index.
01:38Let's call one.
01:40One is 0.
01:42I will execute this as you can see.
01:44As you can see, this is 0.
01:48Now, let's say this is fancy.
01:50For example, I can explain a range.
01:53This is the range of the list.
02:01The one exists.
02:05This is the index 0 to 3.
02:08I will say that this is the comma.
02:11Check 1.
02:12Sorry.
02:130 to 3.
02:15Now, if I execute this as you see,
02:19this is the 0 exists.
02:21However, I will tell you that this is the 0 exists.
02:23I will say that this is the 1 to 3.
02:25That it doesn't exist.
02:28If we don't know anything about one,
02:30then I can execute this.
02:31And it gives me an error.
02:32They will say that the list is not.
02:34This is very important.
02:35You have a list.
02:37You have a list.
02:39You have a list.
02:41You have a list.
02:43You have one list.
02:46You have a list.
02:47There is a banana.
02:49You have a banana.
02:51and banana and this is a laptop.
02:57Now, check if this list is required element or not.
03:05What do you want to do?
03:07For example, banana check.
03:11So, banana check if this list is required or not.
03:17So, banana check if this list is required.
03:23Now, what do you want to do?
03:25Let's do index 1.
03:27Here we go to 3.
03:29Basically, 3 is not.
03:31So, let's do 2.
03:33Sorry.
03:352 and 0.
03:37And I will execute it.
03:39As you see, it says that yes, banana exists.
03:43If there is a number that exists, it's an indication that the item exists in the list.
03:48And this is a helpful feature.
03:50Now, we have some other function.
03:53The top of the list is sort.
03:56Sort.
03:57Sort.
03:58Basically, we can sort the list of items.
04:04Sort.
04:05Sort.
04:06It's simple.
04:07I will run it.
04:08So, now you will see that.
04:09Because it is already ordered.
04:111, 2, 3, 4.
04:12So, this is already ordered.
04:141, 2, 3, 4.
04:15So, this is not a difference.
04:16As you see, this sort is non-return.
04:18Just like older examples.
04:22However, when we assign new numbers.
04:27Sort.
04:28New numbers is equal to this.
04:31And now we can print new numbers.
04:34Print.
04:35Run.
04:36Hum.
04:38So, what is the problem?
04:39Basically, we can run this.
04:40We will run this.
04:41We will none return.
04:42Actually, sort method is not returned.
04:45It is not returned.
04:46It is not returned.
04:48It is not returned.
04:49It is not returned.
04:50The sort method is not returned.
04:53It is not returned.
04:54It is in the original list.
04:55It is in the original list.
04:56So, here I am going to print the number and execute the number, you see 1, 2, 3, 4, 5, 6, 7, 8, and 9, 9.
05:04Now, let's say, a reverse number, let's say, mixed number, mixed underscore num,
05:11I will generate a list so that the sort of effect can be found.
05:15So, let's see, there are some numbers that are found.
05:18So, let's see, there are some bunch of random numbers.
05:21Right?
05:22Here, here, let's say, 7, OK.
05:28So, here bunch of numbers are found.
05:30This is random.
05:31If you use mixed numbers on solid method, then you will know what will.
05:40Mixed numbers on the method and print them.
05:43So, let's see, this is original list.
05:46As you guessed,
05:48Yes, we had an unordered mixed list. However, when we sorted it, we ordered two, three, four, four, four, five, six, seven, nine and so on.
06:02Now, when I have assigned a new list, it has no return. The reason is that the sort method by itself is in the original list, which is not return.
06:15What if I want to return something?
06:17So, this is a method, a function of sorted, which we call.
06:22So, this is a little bit of a difference.
06:25I say sorted, sorted.
06:27Sorted, we give it an iterable.
06:29Let's say mixed value is iterable.
06:32Now, I can assign value to this.
06:37This is new underscore value.
06:42This is sorted method call.
06:44New value.
06:45Now, if I print new value, I will return a list.
06:51This is a list.
06:53Okay?
06:54And if I remember, if I print a new number, then it will return none.
07:01Make sense?
07:03Okay?
07:04Sort method.
07:05Sort method.
07:06So, sorted function.
07:08However, return.
07:10Sort method.
07:11Sort method.
07:12Sort.
07:13Sort.
07:14Basically, organize.
07:15Okay?
07:16So, it will release a list.
07:17So, it will be the same.
07:18So, the method is the same.
07:19I will start in the list.
07:20So, if I draw the list from the other side, it will release a table.
07:22organize
07:23कर देता है पूरी list को
07:24ठीक है अब अगर
07:26आप mix number के उपर
07:28reverse का
07:30method कॉल करें dot reverse
07:33ठीक है क्या करता है
07:35कि यह इस list को उठाएगा
07:36और इसको mirror कर देगा flip कर देगा
07:38मिसाल के तोर पर यह 4 है
07:407 पे आ जाएगा 7 4 पे चला जाएगा
07:429 3 पे आजाएगा 3 9 पे चला जाएगा
07:44and so on
07:45तो अगर मैं इसको run करता हूँ
07:47of course आप ने जहन में रखना है
07:51और इजिनल लिस्ट में चेंज आएगी
07:52क्योंकि यह method कॉल करने है
07:54मैं इसको एक जहन में जहन में रखना है
07:56कि और इजिनल लिस्ट में चेंज आएगी
07:57and as you can guess
08:02this history is changed
08:05however, if you are confused
08:07if you are confused, if you are 4-9
08:09or 7-9, or 7-4
08:11then this is why we don't know
08:13this reason is that we have sorted
08:14and then we are doing reverse
08:18so this is why the order
08:20change is changed
08:21and then we have value
08:23however, when we remove
08:24functions, we remove functions
08:27then we clearly see
08:28that reverse is how to work
08:30basically, 4-7
08:317-4, 9-3, 3-9, 2-4, 4-4
08:36and this position
08:37is basically, what we have
08:39mirroring
08:40left element
08:42middle
08:42middle
08:43left
08:44left
08:44left
08:45left
08:46left
08:47left
08:48now, we have
08:49many functions
08:50cover
08:51however, I strongly recommend
08:53I recommend
08:54I recommend
08:55and I recommend
08:55and to try
08:55to practice
08:57and check
08:57how to do functions
08:58and see
08:59how to do functions
09:00what do functions
09:01do

Recommended