I just want to know why this doesn’t work
(I am trying to name the ducklings from a book: Jack, Kack, Lack, Mack, Nack, Ouack, Pack, Quack) Note: Quack and Ouack have a U
prefixes = 'JKLMNOPQ'
suffix = 'ack'
for letter in prefixes:
if letter != 'O' or 'Q': #I know this doesn't work, need to know alternative
print letter + suffix
else:
print letter + 'u' + suffix
You likely mean this:
The result of your original statement,
compared
letterto the result of'O' or 'Q', which is a boolean (true to be exact) (so you could see why this comparison would always be true as it was).