List Comprehension in Python | List Comprehension Python | Python Interview Question

  Рет қаралды 10,932

Code-yug

Code-yug

Күн бұрын

Пікірлер: 22
@Codeyug
@Codeyug 4 ай бұрын
Master in Python :- kzbin.info/aero/PLI4OVrCFuY543naNBsCaRLrLSxI7MUOzZ
@akashrajendraprasad3717
@akashrajendraprasad3717 11 ай бұрын
U saved me bro , thank you so much, one of the best playlist for python in the whole YT
@Codeyug
@Codeyug 11 ай бұрын
Thanks for the comment, please save others as well.
@kcvinu
@kcvinu 2 жыл бұрын
This video helped me a lot. I wanted to call a function in list comprehension. And I was worrying about how to do that, because all list comprehension tutorials are showing how to do arithmetic ops with the loop variable. But I am too foolish to find the correct position to call my function. At first I wrote print([x for i in my_list x = my_func(i)]). But after watching your video, I got the idea and now I have this -- print([my_func(i) for i in my_list])
@KaranSinghD-yj9ep
@KaranSinghD-yj9ep 2 жыл бұрын
#List comprehension #It is a way to write compact codes. #advantages of comprehension #1.Less code #2.Faster then manul program """ #Type of comprehension 1.list com 2.set com 3.Dictionary com ****List comprehension***** 1.list comprehension syntax1: [expression for var in iterable] 2.if statement [expression for var in iterable if condition] 3.Nested if [expression for var in iterable if condition1 if condition2] 4.If else [expression if cond else expression var in iterable ] """ #simple programming nums = [3,6,8,12,14,15] count=[] for i in nums: count.append(i*i) print(count) #using 1.list comprehension syntax1: [expression for var in iterable] print([i*i for i in nums]) #2 nums = [3,6,8,12,14,15] count=[] for i in nums: if i%2==0: count.append(i*i) print(count) #2.if statement [expression for var in iterable if condition] print([i*i for i in nums if i%2==0]) #3 nums = [3,6,8,12,14,15] count=[] for i in nums: if i%2==0: if i%3==0: count.append(i*i) print(count) #3.Nested if [expression for var in iterable if condition1 if condition2] print([i*i for i in nums if i%2==0 if i%3==0]) #4 nums = [3,6,8,12,14,15] count=[] for i in nums: if i%2==0: count.append(i*i) else: i%2!=0 count.append(i*i*i) print(count) #4.If else [expression if cond else expression var in iterable ] print([i*i if i%2==0 else i*i*i for i in nums]) #5 nested for loop lst=[] for i in range(2,6): for j in range(3,5): lst.append(i*j) print(lst) #using comprehension print([i*j for i in range(2,6) for j in range(3,5)])
@Eliminatetheviel.369
@Eliminatetheviel.369 Ай бұрын
Blessing from god. Respecte from heart
@technicalabhi7683
@technicalabhi7683 Жыл бұрын
Nice
@sourabhmori8129
@sourabhmori8129 Жыл бұрын
Sir tuple comprehenssion bhi hota he, someone told me.
@Codeyug
@Codeyug Жыл бұрын
Tuple comprehension nhi hota hai, it's actually generator. Generator ke video me explain koya hai. Check first 5 mins of kzbin.info/www/bejne/Y3jEe5urdpxsbM0feature=shared
@sourabhmori8129
@sourabhmori8129 Жыл бұрын
@@Codeyug OK sir I will check this, thank you for replying me . 😇
@pavankushwaha8273
@pavankushwaha8273 2 жыл бұрын
Thanks 👍🙏
@sunitapandey-vq2mf
@sunitapandey-vq2mf 3 ай бұрын
❤❤
@TppJay
@TppJay Жыл бұрын
You are genius brother ❤
@Codeyug
@Codeyug Жыл бұрын
Please do share..
@TppJay
@TppJay Жыл бұрын
@@Codeyug for sure❤️
@improveyourlisteningskills2116
@improveyourlisteningskills2116 2 жыл бұрын
How do I use elif in list comprehension
@Codeyug
@Codeyug 2 жыл бұрын
Nice question.. I will create a video on this by today or tomorrow evening..
@improveyourlisteningskills2116
@improveyourlisteningskills2116 2 жыл бұрын
Thanks a lot
@improveyourlisteningskills2116
@improveyourlisteningskills2116 2 жыл бұрын
I'm waiting for you video
@Codeyug
@Codeyug 2 жыл бұрын
@@improveyourlisteningskills2116 will create today... And upload it on morning
@abhishekdubey9920
@abhishekdubey9920 8 ай бұрын
Fucking good
@Codeyug
@Codeyug 8 ай бұрын
Do share plz
Jaidarman TOP / Жоғары лига-2023 / Жекпе-жек 1-ТУР / 1-топ
1:30:54
Andro, ELMAN, TONI, MONA - Зари (Official Music Video)
2:50
RAAVA MUSIC
Рет қаралды 2 МЛН
List & Dictionary Comprehension in Python 🐍 with Execution
6:34
Gate Smashers
Рет қаралды 16 М.
List Comprehension in Python (Hindi)
31:45
Geeky Shows
Рет қаралды 35 М.