我的IF语句如下:
...
if word.endswith('a') or word.endswith('e') or word.endswith('i') or word.endswith('o') or word.endswith('u'):
...
在这里,我不得不使用4个OR来覆盖所有情况。无论如何,我可以简化一下吗?我正在使用Python 3.4。
尝试
if word[-1] in ['a','e','i','o','u']:
其中word [-1]是最后一个字母
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句