Decoding

Q:
In the war against Skynet, humans are trying to pass messages to each other without the computers realising what’s happening.

To do this, they are using a simple code:

They read the words in reverse order
They only pay attention to the words in the message that start with an uppercase letter
So, something like:

BaSe fOO ThE AttAcK

contains the message:

attack the base

However, the computers have captured you and forced you to write a program so they can understand all the human messages (we won’t go into what terrible tortures you’ve undergone). Your program must work as follows:

code: soMe SuPPLies liKE Ice-cREAm aRe iMPORtant oNly tO THeir cReaTORS. tO DestroY thEm iS pOInTLess.
says: destroy their ice-cream supplies

Notice that, as well as extracting the message, we make every word lowercase so it’s easier to read.

A:

code = input("code: ")
list_code = code.split()
list_code.reverse()
words = ''
for word in list_code:
  if word[0].isupper() == True:
    words += word + " "
says = words.rstrip()
print("says:", says.lower())
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值