List Comprehension Basics with Python (Python Tutorial #12)

preview_player
Показать описание
List comprehension basics in Python - let's go!

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

There's also a function call "reversed".

e4 = [x ** 2 for x in reversed(range(1, 7))]

atony
Автор

YK please upload Python video frequently please:)

bhavikakapadia
Автор

I'm taking a beginners Python course on Udemy and the course is getting a tad more difficult so I come over to yt and watch CS Dojo and it all makes sense. It fits perfect. Thanks a lot dude!

Gurgs
Автор

YK, don't give up on us please ... please continue with your amazing Python basics videos

archstampton
Автор

We can also do it by creating range(-6, 0).and then do it in the exact same way as before..

kalyanbaidya
Автор

Hi YK, what I love about your videos is that you make it look very simple. Please keep adding more Python related topics in your tutorials.

kamalagrawal
Автор

we can use map function here as well:
list1 = [1, 3, 5, 7, 9, 11]

list2 = list(map(lambda x: 2*x, list1))
print(list2)

viveksundaray
Автор

You are a life saver. I've been taking a break from projects until I learn python better. You've been my favorite channel to watch. 😊

BadMathGavin
Автор

YK, this is my very first time learning python, and your videos make it so simple. Great work! Simplicity at best!

satyamgupta
Автор

# using append:
p = []
for q in range(6, 0, -1):
p.append(q ** 3)
print(p)

#using list comprehension:

p = [q ** 3 for q in range(6, 0, -1)]
print(p)

juwel
Автор

This code works as well:
a = list(range(1, 7))
c = [ i**2 for i in a]
c.reverse()
print(c)

Happy Coding!! :)

kolachalamasudhasrinidhi
Автор

You’re the best python teacher on YouTube thanks so much 😊😊😊

sirlogicghana
Автор

b = []
for i in range(1, 7):
b.append(i**2)

b.reverse()
print(b)

xedwardz
Автор

Great work YK !
Love these python videos.
BTW, any chance we could see Machine learning tutorials on this channel?
That would be super awesome. 😍

dark.prnx.
Автор

My solutions to the challenge before hearing about how you could make a reversed range() :

list2 = [(x * -1 + 7) ** 2 for x in range(1, 7)]
print(list2)

list3 = []
for x in range (1, 7):
list3.append((x * -1 + 7) ** 2)
print(list3)

olliveraira
Автор

Thank you, just in time when my class is beginning to learn lists.

terellkantwell
Автор

Unlikely you see this 3 years later but thank you, this was the first thing to really give me trouble in my Python introductory course.

RoxiieReadsLore
Автор

please create more videos on python and if you get time, please try on making videos on interview questions .
Thanks ! ! !
i watch all your ads also ..

nitinjain
Автор

Another way to reverse a list is to use print(a[::-1]) where a is the list.

Example:
a = [1, 2, 3, 4, 5, 6]
b = [x * 2 for x in a]
print(b[::-1])

manatwork
Автор

Thank you for starting this series again.

proudlyindian