Comprhension in the python

technical talkiess
0

 Comprehension in python :- 


# python comprehension


# this is called comprehension ... list comprehension

ls = [i for i in range(100) if i%2==0]



# dictionary com[rehension ]


dict = {i:f"Item {i}" for i in range(5)}

# agar apko isko ulta karna hai to

dict1 = {value:key for key,value in dict.items()}


# agar aap isko set karte ho to wo dublicate value ko remove kar denga

test = {i for i in ['visaha','kaka','vishal','kaka','mama','test']}


# genrators comprehension

gen =(i for i in range(100) if i%2==0)

# print(gen.__next__())

# print(gen.__next__())

# print(gen.__next__())

# print(gen.__next__())


Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)