首先,这是我的代码:
s = raw_input("code: ")
s1 = " ".join(s.split()[::-1])
lists = s1.split()
for i in lists:
if i.istitle() == True:
print i
它目前所做的是反转一个字符串,如果它以大写字母开头,则打印一个单词。然而问题是,如果一个词像“大写”,它不会打印出来。
让我展示一些我希望程序如何工作的示例:
- 以相反的顺序阅读单词
只注意邮件中以大写字母开头的单词
如果输入:BaSe fOO The AttAcK 那么它应该返回:攻击基地
另一个例子:
code: soMe SuPPLies liKE Ice-cREAm aRe iMPORtant oNly tO THeir cReaTORS. tO DestroY thEm iS pOInTLess.
says: destroy their ice-cream supplies
太感谢了!