List Comprehension
List Comprehension
1 Normal writing Code
lst=[1,2,4,5,7,9]
for i in range(lst[0],lst[-1]+1): #ye sab apn list comprehension se kr skte hai
if i not in lst:
print(i)
2 YE list comprehension ke saath
def FindMissing(lst):
return[i for i in range(lst[0],lst[-1]+1)
if i not in lst ]
lst=[1,2,4,5,6,8,9,11,14,16]
print(f"These are Missing Numbers = {FindMissing(lst)}")
Source--------- https://youtu.be/m3yd3N57nVY
Comments
Post a Comment