0 votes
1 view
in Python by (8.4k points)

I have a set like this:

keep = set(generic_drugs_mapping[drug] for drug in drug_input)

How do I add values [0,1,2,3,4,5,6,7,8,9,10] into this set?

1 Answer

0 votes
by (16.8k points)

First, use : 

keep.update(yourvaluesequence)

Like, keep.update(xrange(11) specifically for your example. In case you want to produce the values in a loop for some other reason, then you can, by using:

for ...whatever...:

  onemorevalue = ...whatever...

  keep.add(onemorevalue)

Related questions

+3 votes
2 answers
0 votes
2 answers
0 votes
2 answers
asked Oct 3 in Python by Tech4ever (22.4k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...