擅长:python、mysql、java
<p>我们可以在特定的位置检查辅音或元音中的特定字符串,并在当前迭代中条件求值为真时继续下一次迭代</p>
<p>如果任何条件在任何迭代中失败,它将返回false。如果条件对所有迭代的计算结果都为True,那么函数最终将返回True</p>
<pre><code>consonants = "bcdfghjklmnpqrstvwyz"
vowels = "aeiou"
def checkString(st):
for i in range(len(st)):
if i % 2 == 0 and st[i] in consonants:
continue
elif i % 2 != 0 and st[i] in vowels:
continue
else:
return False
return True
</code></pre>