comprehension practice or execrecise in using python

technical talkiess
0

 Comprehension practice:- 

print("Enter how many item do you want to add ")

inum = int(input())

print("Please select where do you want to add the item \n 1.List Comprehension . \n 2.Dictionary comprehension \n  3.Set comprehension ")

which_item = int(input())


print("Enter the item name here...Please enter your item , seprated")

additem = input()

additem = additem.split(',')


if which_item == 1:

    items =[i for i in additem ]

elif which_item == 2:

    items ={i for i in additem}

elif which_item ==3:

    items = (i for i in additem)

       


print("Added items is :- ")

print(items)
Tags

Post a Comment

0Comments

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

Post a Comment (0)