I am creating a Python program that generates items randomly. Is there a way to exclude the items that have not been generated from the results? -


i have program generates list of items based on random numbers.

starting list of variables set 0:

for each item, define different function generate item example:

def item1func():     global item1      rng = randint(0,1)     if rng == 1:         item1 += 1 

after functions have been defined, run functions , print results these statements:

print "%s item 1" % (item 1) print "%s item 2" % (item 2) print "%s item 3" % (item 3) 

so end result prints list of items generated , quantity. instance:

10 item 1  15 item 2  0 item 3 

my question how can print item list if quantity amount?

but since have around 85 different items print each time program run, inefficient implement if statements.

is there simple solution?


Comments