Python 3 Tutorial for Beginners #21 - List Comprehensions

preview_player
Показать описание
Hey gang, in this Python 3 tutorial I'll show you another way to create lists using list comprehensions.

----- COURSE LINKS:

---------------------------------------------------------------------------------------------
Other tutorials:

----- NODE.JS TUTORIALS

============== The Net Ninja =====================

================== Social Links ==================

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

Thanks for the video, a little addition to it; at 6:36-ish (in the comprehension method of even squared numbers) `[ num ** 2 for num in nums if num % 2 == 0 ]` will be sufficient (note no square calculation) because of an even number's square is going to be even too. Using Python (actually computers in general) for scientific purposes is not merely programming, it includes math also. Of course the method I'm talking about has too little impact on performance (it may well be negligible) for the sake of this tutorial but imagine the performance impact with big numbers.

ozanmuyes
Автор

oh man you are amazing :) keep it up. plus, you have gained a subscriber.

mulu
Автор

you are really awesome ! love your videos

abhayraghuvanshi
Автор

One tip I'd give - try and work out the solution by pausing the video before Shaun explains it :)

petecodes
Автор

For the squaring even numbers comprehension method, what's the purpose of the ( )'s in the IF statement. I've tried with your demonstrated ( )'s, without ( )'s, and even ( )'s including the % 2 == 0, which all seem to work. Again, my question is are the ( )'s even important to use in this situation?

clawer
Автор

Would I be correct in saying ES6 has even nicer syntax for these kind of operations, like the spread operator '...array'

lardosian