python 指定字符串 翻转

小鱼儿 2022-05-24 03:20 267阅读 0赞
  1. def spin_words(sentence):
  2. # Your code goes here
  3. lists = sentence.split()
  4. string = ''
  5. results = []
  6. for x in lists:
  7. if len(x) >= 5:
  8. results.append(x[::-1])
  9. else:
  10. results.append(x)
  11. return ' '.join(results)

发表评论

表情:
评论列表 (有 0 条评论,267人围观)

还没有评论,来说两句吧...

相关阅读

    相关 翻转字符串

    翻转字符串 字符串反转 题目分析 翻转字符串(2) 题目分析 字符串反转 来源:牛客网 链接:https://www.n

    相关 翻转字符串

    题目描述 牛客最近来了一个新员工Fish,每天早晨总是会拿着一本英文杂志,写些句子在本子上。同事Cat对Fish写的内容颇感兴趣,有一天他向Fish借来翻看,但却读不懂它的