在 python 上,您如何测试一个字母前面是否有另一个字母?
On python, how do you test to see whether a letter is preceded by another letter?
例如:对于单词中的一个字母,如果该字母前面是元音......
你会如何用 pythonic 语言编写它
例如:
如果 "h" 前面有一个 "s" 在一个单词的任何地方,return(True)
the_word("bash")
True
the_word("sushi")
True
a = 'h'
b = 's'
if b+a in "bash": # True
..
if b+a in "hello": # False
..
if b+a in "sushi": # True
如果你想在函数中使用它,只需将 a 和 b 作为参数
例如:对于单词中的一个字母,如果该字母前面是元音......
你会如何用 pythonic 语言编写它
例如:
如果 "h" 前面有一个 "s" 在一个单词的任何地方,return(True)
the_word("bash")
True
the_word("sushi")
True
a = 'h'
b = 's'
if b+a in "bash": # True
..
if b+a in "hello": # False
..
if b+a in "sushi": # True
如果你想在函数中使用它,只需将 a 和 b 作为参数