Back
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?
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)
for ...whatever...:
onemorevalue = ...whatever...
keep.add(onemorevalue)
31k questions
32.8k answers
501 comments
693 users