- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
例如,如果我输入 bob
,它应该给我 obb
。同样,像 plank
这样的东西应该给我 ankpl
。
s = input("What word do you want translated?")
first = s[0]
vowel = "aeiou"
for i in range (1, len(s)):
if first in vowel:
s = s + "way"
print (s)
else:
s = s[1:] + s[0]
print (s)
这目前只给我 lankp
for plank
。谢谢!
最佳答案
它实际上可以变得更简单:
s = raw_input("What word do you want translated?").strip()
vowel = set("aeiou")
if vowel & set(s):
while s[0] not in vowel:
s = s[1:] + s[0]
print s
else:
print "Input has no vowels"
关于Python程序连续将辅音移动到字符串的末尾,直到第一个字母是元音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19828561/
我正在努力思考如何在句子中表示辅音。我刚才使用的代码似乎无法完成这项工作: vowels = ("aeiou") count = 0 for x in text: if not x in vo
我想为特定的辅音/元音设置生成所有可能的排列。例如,我想要所有可能的 3 字母单词排列,格式为 CVC(辅音、元音、辅音)。 我不知道有什么方法可以乘以排列: permutations("bcdfgh
在问题中,我们得到了 2 个字符串,我们必须数数。元音,没有。辅音并单独显示每个字符串的乘积。 预期输出2 6 120 7 0 输出获取0 0 02 6 12 这是代码- import java.io
我正在尝试计算一个字符串中有多少个元音/辅音/数字/其他符号。 #include #include int main(void) { int cons = 0, vow = 0, num
我确信这很简单,但我是一个完全的初学者。我正在尝试制作一个工具,其中有一个字符串并搜索 'n' + [任何辅音] 并将其替换为该辅音的两倍 - 例如 aaanq -> aaaqq。 我唯一能想到的是,
尝试学习 Python 中的正则表达式以查找具有连续元音-辅音或辅音-元音组合的单词。我将如何在正则表达式中执行此操作?如果无法在 Regex 中完成,是否有一种在 Python 中执行此操作的有效方
我是一名优秀的程序员,十分优秀!