Master in Python :- kzbin.info/aero/PLI4OVrCFuY543naNBsCaRLrLSxI7MUOzZ
@akashrajendraprasad371711 ай бұрын
U saved me bro , thank you so much, one of the best playlist for python in the whole YT
@Codeyug11 ай бұрын
Thanks for the comment, please save others as well.
@kcvinu2 жыл бұрын
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-yj9ep2 жыл бұрын
#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Ай бұрын
Blessing from god. Respecte from heart
@technicalabhi7683 Жыл бұрын
Nice
@sourabhmori8129 Жыл бұрын
Sir tuple comprehenssion bhi hota he, someone told me.
@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 Жыл бұрын
@@Codeyug OK sir I will check this, thank you for replying me . 😇
@pavankushwaha82732 жыл бұрын
Thanks 👍🙏
@sunitapandey-vq2mf3 ай бұрын
❤❤
@TppJay Жыл бұрын
You are genius brother ❤
@Codeyug Жыл бұрын
Please do share..
@TppJay Жыл бұрын
@@Codeyug for sure❤️
@improveyourlisteningskills21162 жыл бұрын
How do I use elif in list comprehension
@Codeyug2 жыл бұрын
Nice question.. I will create a video on this by today or tomorrow evening..
@improveyourlisteningskills21162 жыл бұрын
Thanks a lot
@improveyourlisteningskills21162 жыл бұрын
I'm waiting for you video
@Codeyug2 жыл бұрын
@@improveyourlisteningskills2116 will create today... And upload it on morning