for x,y in enumerate(l): if y == 'Q': aaa.append(x)
Add a code snippet to your website: www.paste.org