No video

Python Tutorial: For Loop vs Map vs List Comprehensions

  Рет қаралды 3,280

Web Dev Cody

Web Dev Cody

4 жыл бұрын

Python Tutorial: For Loop vs Map vs List Comprehensions
In this python tutorial for beginners, I talk about the difference between using a for loop, the map function, and list comprehension to modify and return a new list. Mapping over arrays is something we do in programming all the time, and there are different ways to achieve the same result. It's good to know all the different ways you can do it in python.
For those who don't know, I'm a full stack web developer who has been in the industry for over 5 years now. There is a lot of things I have learned along the way and I'd like to share that knowledge with anyone wanting to learn!
like this video if you found it useful and would like to see more videos of the same content.
subscribe to my channel if you are trying to improve your abilities as a web developer, software engineer, or even if you are just learning to code.
Don't forget to turn on those bell notifications!
I hear you like notifications, so follow me on social media!
Twitter - / codylseibert
Instagram - / seibert_cody
So you'll never forget, here are my links: bookmark them!
KZfaq - github.com/cod...
My Blog - codyseibert.gi...
Discord - / discord
I give credit to:
Toptal Subtle Patterns - for the thumbnail background patterns

Пікірлер: 17
@kylemueller
@kylemueller 3 жыл бұрын
If you want to unbind a map object and put it in a list, you can use the following shorter syntax: [*map(fn,lst)] You can do the essentially the same thing if you want to put it in a set: {*map(fn,lst)} Extra tip: You can print line by line with map: [*map(print,lst)] It doesn't look like it should work, but it does. Pretty cool, right?
@WebDevCody
@WebDevCody 3 жыл бұрын
That’s neat, I’ll have to check it out
@ninesquared81
@ninesquared81 3 жыл бұрын
You don't actually need a lambda to call the capitalize method in the map function. If you write it in the form str.capitalize, it will call the capitalize method from the built-in str class on each object in the list. It's a lot neater and probably quicker because you don't have to mess around with lambdas.
@kylemueller
@kylemueller 3 жыл бұрын
I was just going to comment this lol. Good thing I checked first
@ironmonkey1990
@ironmonkey1990 4 күн бұрын
thank you!
@orion_222
@orion_222 4 жыл бұрын
great vid man. you'll be famous one day no cap
@snake1625b
@snake1625b 6 ай бұрын
Nice video. Have you noticed the industry lean more towards map over list comprehension
@filmfloyd8751
@filmfloyd8751 3 жыл бұрын
man you are the best
@ianpan0102
@ianpan0102 4 жыл бұрын
To disable the popups that kept coming up (as you mentioned yourself), set "editor.parameterHints.enabled": false
@WebDevCody
@WebDevCody 4 жыл бұрын
I'll check that out, thanks for the tip!
@BrendanMetcalfe
@BrendanMetcalfe 4 жыл бұрын
Nice video!
@WebDevCody
@WebDevCody 4 жыл бұрын
Glad you enjoyed it
@simenandreasknudsen9272
@simenandreasknudsen9272 3 жыл бұрын
This is great, thanks! I find the List Comprehensions to be the most understandable. Are there any speed difference between those? Like if you wanted to make a project run as smoothly and fast as it can
@WebDevCody
@WebDevCody 3 жыл бұрын
I doubt there is much speed difference and I’d assume python would do some performance for tuning under the hood regardless of your iteration approach, but the best way is to test it out yourself
@simenandreasknudsen9272
@simenandreasknudsen9272 3 жыл бұрын
@@WebDevCody thanks man!
@tomparatube6506
@tomparatube6506 3 жыл бұрын
Nice IDE. I like the big buttons for Run and Debug. What is it called? Thanks for great video.
@WebDevCody
@WebDevCody 3 жыл бұрын
Vscode!
List comprehension vs filter in Python (speed, lambda, history, examples)
16:18
Smart Sigma Kid #funny #sigma #memes
00:26
CRAZY GREAPA
Рет қаралды 19 МЛН
Joker can't swim!#joker #shorts
00:46
Untitled Joker
Рет қаралды 38 МЛН
لااا! هذه البرتقالة مزعجة جدًا #قصير
00:15
One More Arabic
Рет қаралды 51 МЛН
Software developers are officially cooked
8:57
Web Dev Cody
Рет қаралды 3,6 М.
Coding a Horoscope App in Python for Beginners
18:37
Web Dev Cody
Рет қаралды 6 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 298 М.
THIS is Why List Comprehension is SO Efficient!
5:25
b001
Рет қаралды 171 М.
#43 Python Tutorial for Beginners | Filter Map Reduce
11:34
Telusko
Рет қаралды 576 М.
Is map faster than a for loop in JavaScript? (no, but sometimes yes)
8:44
Tom on the Internet
Рет қаралды 1 М.
Python's map() Function: Transforming Iterables
21:20
Real Python
Рет қаралды 4,2 М.