dear pythonistas

in the code below

>>> import string, itertools
>>> s = ['ab','ac','bc','ad','ae','de']
>>> count = 0
>>> for startlist in itertools.combinations(s, 3):
>>>      count = count + 1
>>>      stl = list(startlist)
 >>>     print count, stl
>>>      for pair in s:
>>>          x = stl.count(pair)
>>>          print x, pair

the variable stl produces 20 lists. The variable x counts how many times the 
items of s occur in each of the 20 lists.
How can I concatenate the 20 lists in oder to get one count for each of the 
items in s , for example 10 for 'ab'?
My further task will be expand s to all 26 letters oft he alphabet (giving 325 
items) and the to eliminate all list in which the items in s occur more than 
once.

Thank you for help, Marcus.



---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to