小编Ali*_*far的帖子

我的问题有什么不同的方法?

我是 python 新手,遇到了一个问题:我的任务是 "Given a sentence, return a sentence with the words reversed"

例如 Tea is hot --------> hot is Tea

我的代码是:

def funct1 (x):
    a,b,c = x.split()
    return c + " "+  b + " "+ a

funct1 ("I am home")
Run Code Online (Sandbox Code Playgroud)

它确实解决了答案,但我有两个问题:

  1. 如何在不添加空格连接的情况下提供空间
  2. 除了拆分还有其他方法可以逆转吗?

谢谢你。

python python-3.x

6
推荐指数
1
解决办法
54
查看次数

标签 统计

python ×1

python-3.x ×1