>>> text = "i c u"
>>> letter = "u"
>>> any(letter in word and len(word) > 1 for word in text.split())
False
>>> text = "umbrella"
>>> any(letter in word and len(word) > 1 for word in text.split())
True
您可以将letter in word更改为letter.lower() in word.lower(),这取决于您是区分大小写还是nt。
您可以将
letter in word
更改为letter.lower() in word.lower()
,这取决于您是区分大小写还是nt。假设您的意思是“in a word”to be“两边至少有一个字符是“word character”,那么这将起作用:
相关问题 更多 >
编程相关推荐