if letter == 'O' or 'Q':
does not do what you think it does (see here for operator precedence), it's equivalent to:
if (letter == 'O') or ('Q'):
And, since 'Q'
is a truthy value, the condition of that if
statement is always true. What you would need in your case would be:
if letter == 'O' or letter == 'Q':
but a more Pythonic way would be:
if letter in ['O', 'Q']:
This also better matches your original thinking where you want to detect if the letter is any of a certain group of letters, rather than explicitly checking the letter against each and every one.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…