I'm writing a pig latin decoder. This section works with 'qu' works but currently only is the third letter of the word is a vowel. I am implementing an if statement to get it to work for words that have a consonant as the third letter, but keep getting this error: TypeError: 'in ' requires string as left operand, not list
Here is my code:
if w[-2:] == 'ay':
RegW = []
y = w.find('-')
beginningw = w[y:]
if vowel not in beginningw[0]:
RegW.append(beginningw[0:-2] + w[0:y])
else:
RegW.append('qu' + w[0:y])
return RegW[0]
It works for these word: ay-quay (quay) iz-quay (quiz) eue-quay (queue)
but NOT an-quray (quran) (returns quan w/o if statement I'm trying to)
If vowel
is a list of vowel characters, I think you want this:
if beginningw[0] not in vowel:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.