字符串单词顺序反转python_如何在Python中反转字符串中的单词(而不是反转整个字符串)?...

问题是这样的,但是我不能做5号弦的反转。

句子要加密如下。在

•将句子作为字符串读入,称为string1。在

•使用循环创建string2。它是没有空格的string1。在

•使用循环创建string3。它包含字符串1中的所有字符,每四个字符后加一个空格。在

•使用循环创建string4。每个字符都被字母表中的下一个字符替换,空格被“*”替换,“Z”或“Z”被“a”或“a”替换

•使用循环或嵌套循环(循环内的循环)创建string5。每组四个字符中用“*”隔开的字符颠倒过来。在

例如If string1=“猫坐在垫子上”string2 = “Thecatsatonthemat”

string3 = “Thec atsa tont hema t”

string4 = “Uifd*butb*upou*ifnb*u”

string5 = “dfiU*btub*uopu*bnfi*u”

我已经做过了,但是第五行不行:

^{pr2}$

这是程序运行时得到的结果:Enter sentence: The cat sat on the mat

u*bnfi*uopu*btub*dfiU

string 1 = The cat sat on the mat

string 2 = Thecatsatonthemat

string 3 = Thec atsa tont hema t

string 4 = Uifd*butb*upou*ifnb*u

string 5 = u*bnfi*uopu*btub*dfiU

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值