fork download
  1. import re
  2.  
  3. x = [['AATG', 'ATAT', 'GGCC'],
  4. ['CCTA', 'TCGT', 'AAAA'],
  5. ['TTAA', 'GGAT', 'TACA']]
  6.  
  7. pattern = re.compile('[AT]{4}')
  8.  
  9. y = []
  10. for i in range(len(x[0])):
  11. y.append(len([j[i] for j in x if pattern.match(j[i])])/len(x))
  12. print(y)
Success #stdin #stdout 0.01s 27744KB
stdin
Standard input is empty
stdout
[0.3333333333333333, 0.3333333333333333, 0.3333333333333333]