Python Tutorial: Comprehensions - How they work and why you should be using them

preview_player
Показать описание
Python comprehensions are a very natural and easy way to create lists, dicts, and sets. They are also a great alternative to using maps and filters within python. If you are using maps, filters, or for loops to create your lists, then most likely you could and should be using comprehensions instead.

In this video, we will look at how comprehensions work, why you should be using them, and the benefits they have over the alternatives.

The code from this video can be found at:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:

#Python
Рекомендации по теме
Комментарии
Автор

8 years after and my man is still better than 90% of other tutorial, cheers man

just_living_
Автор

Corey I hope you always go to bed feeling good about your work and helping out the community. Thanks for your very clear tutorials.

zackm
Автор

I have to say that your videos are among the best that I've found on youtube for learning python.
You're very well spoken, and your examples are great at illustrating the concepts!

SSCrow
Автор

1st time seen this explained, I agree, your lack of "ummms, uhs, hold-ons, etc." are very pleasing to the ear, great instructor. Thanks.

jeffreystockdale
Автор

Corey, you have really helped me to make the leap from beginner to intermediate Python programmer. I'd heard of list comprehensions before, but never dictionary comprehensions. Once again, many many thanks!

kerwinso
Автор

To be frank, this is the best video for learning about list comprehension on Youtube!

ajith
Автор

at 12:00 you are able to create dict from zip:
dict(zip(names, heros))

vinc
Автор

This is an exceptional tutorial on list comprehensions. The use of writing out what we want in normal language, seeing it implemented in a loop, and then how it translates to a list comprehension makes it very clear and intuitive. I never quite got comfortable with them when I originally learnt this, but your method of teaching it allowed me to understand the concept. Many thanks.

buzz.b
Автор

You just saved me on my homework assignment. I looked at several resources online and asked three different people and your video is the only thing that made the light bulb in my head turn on (in learning dictionary comprehensions)!! Thank you.

kedwards
Автор

the amount of material I have learned from this channel is literally amazing!

RandomShowerThoughts
Автор

I just started learning Python and decided to rewrite a program in Python that I first wrote in C++. I wanted to use a lot of these Python features to eliminate all those those for-loops. So far, my Python program is turning out to be a lot more complex than I thought it would be. (I think I'm over-thinking the problem.) I'm hoping I can use list comprehension to eliminate a lot of that coding and fully utilize the power of Python. I happened to find your video, and I know it is really going to help me. I was also looking for a way to code, debug, and run .py files. You are doing things in Sublime Text that I didn't know you could do. I'm looking forward to watching the video again and following along, as well as watching more of your videos.

MegaJohn
Автор

04:15
python 3.6 should this:
my_list = list(map(lambda n: n * n, nums))

nasalee
Автор

Corey, I never leave any comments under YT videos but man, your tutorials are just something else. Cannot THANK YOU enough for being such an amazing teacher. I love everything about them: the way you explain concepts, carefully go through examples over and over again...and you just sound like a cool guy!
Thanks for everything Corey, truly appreciate you are here for us.

mateuszpolanski
Автор

CONCISE and ELOQUENT are the words for you. First content youtube channel that I don't have to speed up the videos. Thanks!!!

uiato
Автор

A person could be a good programmer but good programmer != good teacher. You are the best python teacher on YouTube.
Thanks for making our lives easier by putting the hard work in making those videos and explaining the concepts in simple and understandable form.

Also, whenever you have time, please consider making video on decorators.

VMSaloudi
Автор

Just spent a couple hours reading articles, watching videos, and practicing nested comprehensions. The whole time I was thinking "wow if Corey had a video on this it would have been so much faster and easier to understand!" Your channel is awesome :)

amandaahringer
Автор

This was the most comprehensive video I've seen on comprehension.

jehushaphat
Автор

Glad I found your channel.

I am working my way through Automate the Boring Stuff with Python and stopping after every chapter and watching your videos has helped so much in understanding the topics in greater detail.

Ryebanana
Автор

oh simply AWESOME.. You teach way better than most of the python tutors. Your detailed explainations are dope.

sahilsharma-hjgq
Автор

I'm so mad at the viewers for not subscribing.. Mate you DESERVE a million subscribers.

riyan
join shbcf.ru