tags:

views:

40

answers:

2

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] in to this set?

+3  A: 
keep.update(yoursequenceofvalues)

e.g, keep.update(xrange(11)) for your specific example. Or, if you have to produce the values in a loop for some other reason,

for ...whatever...:
  onemorevalue = ...whatever...
  keep.add(onemorevalue)

But, of course, doing it in bulk with a single .update call is faster and handier, when otherwise feasible.

Alex Martelli
+1, beat me to it.
sberry2A
+1  A: 

use update like

keep.update(newvalues)

sberry2A