Skip to playerSkip to main contentSkip to footer
  • 5/17/2025
append(): Syntax: list_name.append(element) ...
copy(): Syntax: list_name.copy() ...
clear(): Syntax: list_name.clear() ...
count(): Syntax: list_name.count(element) ...
extend(): Syntax: list_name.extend(iterable) ...
index(): Syntax: list_name.index(element) ...
insert(): ...
pop():
Transcript
00:00Hello and welcome back guys.
00:05In this lecture, I am going to teach you how we can create lists automatically.
00:11Now you have seen that when the list is created,
00:14I wrote some names and said numbers is equal to
00:19and then 1, 2, 3, 4, 5, 6, 7.
00:23This is quite boring.
00:25The second issue is that the list is not 1-9.
00:31We all know that in real world, there are no green garden and rainbows.
00:35In real world, there are no edgy projects.
00:39The list is not so large.
00:42There is no method to generate lists automatically.
00:51Yes, there is a method.
00:54There is a function.
00:56There is a function.
00:58It is called range.
01:00Range basically, our list is automatically created.
01:04Now, if I say range,
01:08Range is the feature of start point and end point.
01:12For example, I want to create 1-10.
01:161, 10.
01:18If I print it, you will see nothing.
01:22You will see an iterator.
01:24You will see range 1-10.
01:26Range 1-10.
01:28Range 1-10.
01:30However, if I convert it in list,
01:34So, as you remember,
01:36We have started with int-math type conversion.
01:40Str type conversion.
01:42Integer, string, string, integer.
01:44This is a list.
01:46Basically, if you give an iterator,
01:48you will convert it.
01:50So, I put the list here.
01:52I put the range here.
01:54I will wrap this range.
01:56I will wrap this range.
01:58I will run this.
02:00Let's see what happens.
02:02Balance is not a problem.
02:04Balance is not a problem.
02:06Now, we run this.
02:08And Kaboom, Shaka, Laka,
02:101-10.
02:12Now, interesting enough,
02:14You can create 1-100.
02:16It's totally up to you.
02:17And actually, you can create 1-2000.
02:19It's not a problem.
02:21And this is one of the main reasons
02:24You will have to work with very big lists.
02:29You can create them just like that.
02:33Before closing this lecture,
02:35I will tell you a big trick.
02:38I will tell you that
02:40when we were the variable assignment
02:41we were able to assign two variables
02:43in one statement.
02:45We can assign two variables.
02:46We can assign two variables.
02:47I will say a comma b is equal to 1 comma 2.
02:49And in this case,
02:50if I print it.
02:52Print.
02:53Print.
02:54Print.
02:55Print.
02:56Print.
02:57Print.
02:58Print.
02:59Print.
03:00Print.
03:01Print.
03:02Print.
03:03Print.
03:04Print.
03:05Print.
03:06Print.
03:07Print.
03:08Print.
03:09Print.
03:10Print.
03:11Print.
03:12Print.
03:13Print.
03:14Print.
03:15Print.
03:16Print.
03:17Print.
03:18Print.
03:19Print.
03:20Print.
03:21Print.
03:22Print.
03:23Print.
03:24Print.
03:25Print.
03:26Print.
03:27Print.
03:28Print.
03:29Print.
03:30Print.
03:31Print.
03:32Print.
03:33Print.
03:34There is such a way that I say,
03:36okay, first two values,
03:38and the other ones are separate.
03:40Then,
03:42we put a comma and a hysteric.
03:46Then, I say, remaining.
03:48Okay, remaining list.
03:52Make sense?
03:54I will execute this.
03:56I will give you two values.
03:58The other one will give you two values.
04:00The remaining list is the variable.
04:02Now, as you see, one, two, three, and remaining list.
04:12It's cool.
04:14It's very, very cool.
04:16It's very, very cool.
04:18Now, range.
04:20You can unpack list in the way you want.
04:24You can unpack list in the way you want.
04:28Now, for example,
04:30the star remaining will go to the end.
04:34The first one will go to the end.
04:36But if you have a value assign,
04:40the final value will go to the end.
04:42The second one will be assigned.
04:44For example, I will say,
04:46ABCD.
04:48Then, the seven will assign.
04:50And the six will be available.
04:52I'll print it.
04:54In print, we say,
04:56and we run it, and we run it, and kaboom, shaka, laaka.

Recommended