华为机考入门python3--(13)牛客13-句子逆序

分类:列表

知识点:

  1. 列表逆序(和字符串逆序是一样的) my_list[::-1]

题目来自【牛客】

python 复制代码
def reverse_sentence(sentence):  
    # 将输入的句子分割
    words = sentence.split()  
    # 将单词逆序排列  
    words = words[::-1]  
    # 将单词用空格连接起来,并添加一个空格在最后  
    reversed_sentence = ' '.join(words)
    return reversed_sentence

input_str = input().strip()
print(reverse_sentence(input_str))

by 软件工程小施同学

相关推荐
熊猫钓鱼>_>2 小时前
【开源鸿蒙跨平台开发先锋训练营】Day 7:开源鸿蒙开发第一阶段复盘与技术深度总结
react native·华为·开源·harmonyos·arkts·openharmony·rnoh
星火开发设计2 小时前
枚举类 enum class:强类型枚举的优势
linux·开发语言·c++·学习·算法·知识
程序员清洒7 小时前
Flutter for OpenHarmony:GridView — 网格布局实现
android·前端·学习·flutter·华为
嘴贱欠吻!7 小时前
Flutter鸿蒙开发指南(七):轮播图搜索框和导航栏
算法·flutter·图搜索算法
Miguo94well7 小时前
Flutter框架跨平台鸿蒙开发——地理知识速记APP的开发流程
flutter·华为·harmonyos·鸿蒙
张祥6422889047 小时前
误差理论与测量平差基础笔记十
笔记·算法·机器学习
qq_192779878 小时前
C++模块化编程指南
开发语言·c++·算法
时光慢煮8 小时前
【Flutter × OpenHarmony】跨端开发实现全局Toast提示卡片
flutter·华为·开源·openharmony
讯方洋哥9 小时前
HarmonyOS App开发——鸿蒙音乐播放机应用App开发
华为·harmonyos
cici1587410 小时前
大规模MIMO系统中Alamouti预编码的QPSK复用性能MATLAB仿真
算法·matlab·预编码算法