Python list comprehension 📰
Ғылым және технология
python list comprehension tutorial example explained
#python #list #comprehension
list comprehension = a way to create a new list with less syntax
can mimic certain lambda functions, easier to read
list = [expression for item in iterable]
list = [expression for item in iterable if conditional]
list = [expression if/else for item in iterable]
--------------------------------------------------------------
squares = [] # create an empty list
for i in range(1,11): # create a for loop
squares.append(i * i) # define what each loop iteration should do
print(squares)
create a list AND defines what each loop iteration should do
squares = [i * i for i in range(1,11)]
print(squares)
--------------------------------------------------------------
Пікірлер: 52
tldr # list comprehension = a way to create a new list with less syntax # can mimic certain lambda functions, easier to read # list = [expression for item in iterable] # list = [expression for item in iterable if conditional] # list = [expression if/else for item in iterable] # -------------------------------------------------------------- squares = [] # create an empty list for i in range(1,11): # create a for loop squares.append(i * i) # define what each loop iteration should do print(squares) # create a list AND defines what each loop iteration should do squares = [i * i for i in range(1,11)] print(squares) # -------------------------------------------------------------- students = [100,90,80,70,60,50,40,30,0] passed_students = list(filter(lambda x: x >= 60, students)) passed_students = [i for i in students if i >= 60] # passed_students = [i if i >= 60 else "FAILED" for i in students] print(passed_students) # --------------------------------------------------------------
I like how you have around 83k in the first video of the series and on this you have only around 4k, I won't give up like others Im going to stay here till I learn this complete.
@jasonunterwegs8991
Жыл бұрын
4 Months later hope you stayed consistend!
@ombrenombre7496
Жыл бұрын
@@jasonunterwegs8991 i did
@jasonunterwegs8991
Жыл бұрын
@@ombrenombre7496 glad to hear that! best luck for the next 4 months
@Goose____
Жыл бұрын
one year later, hopefully you're still consistent
@kapibara2440
8 ай бұрын
Same with me!
Straight to the point. Great content 👌
Genio total!! Thank you very much!
Thank you! Very useful
another perfect video
Love it, thanks bro!
very nice video
Thank you!
I liked I commented I subscribed months ago, I hope i keep this channel running :)
thx 4 vid bro ~!
Excellent tutorial. Tq. Subbed.
I'll never let this channel die😭
thanks for sharing code in comments, very useful
Question: Can you actually put an elif statement into a list comprehension? Your videos help me a lot btw, thank you so much!
dude much love for you
Thanks for every thing
thanks :)
Excellent content bro!
Thanks Bro
Beating the algorithm for you :-)
i like this
Ty Bro
good video
Wow!
thanks
🐐
thanks.
Thanks
Takes a bit of getting used to, but worth trying
@jasonunterwegs8991
Жыл бұрын
@every thing yo just asking how are you doing in python after 3 months? hope you do good m8
excellent
Great job, but how about one that has compound comprehensions?
lovw u
Who else if learning to code as a beginner?
support
Dear bro, I love your vids but is there any chance that you can add like 5 exercises at the end of your video for every topic you do, maybe a link to github rep will do. thaanks
meow~!
List comprehension feels circular and self referential to me. i for i in i for i. Like...WHAT.
YALLA
Just an comment
bro code can make me come
comment
List comprehension is cool, dict comprehension is shi
thanks