华为机考入门python3--(0)模拟题2-vowel元音字母翻译

分类:字符串

知识点:

  1. 字符串转list,每个字符成为list中的一个元素 list(string)

  2. 字符串变大小写 str.upper(), str.lower()

题目来自【华为招聘模拟考试】

python 复制代码
# If you need to import additional packages or classes, please import here.

def func():

    # please define the python3 input here. For example: a,b = map(int, input().strip().split())
    sentence = input().strip()
    my_list = list(sentence)
    # ['w', 'h', 'o', ' ', 'l', 'o', 'v', 'e']
    # print(my_list)
    
    vowels = ('a','e','i','o','u','A','E','I','O','U')
    new_my_list = []
    for letter in my_list:
        if letter in vowels:
            new_my_list.append(letter.upper())
        elif letter == ' ':
            new_my_list.append(letter)
        else:
            new_my_list.append(letter.lower())
    
    # print(new_my_list)
    new_sentence = ''.join(new_my_list)
    print(new_sentence)
    # please finish the function body here.
    # please define the python3 output here. For example: print().

if __name__ == "__main__":
    func()

by 软件工程小施同学

相关推荐
小白学大数据12 小时前
分布式爬虫核心技术详解与工程实践
开发语言·分布式·爬虫·python
Ulyanov12 小时前
打造现代化雷达电子对抗仿真界面 第二篇:雷达电子对抗仿真系统核心功能实现
前端·python·信息可视化·数据可视化·系统仿真·雷达电子战
财经资讯数据_灵砚智能12 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(夜间-次晨)2026年4月12日
人工智能·python·信息可视化·自然语言处理·ai编程
见山是山-见水是水12 小时前
鸿蒙flutter第三方库适配 - 页面转场应用
flutter·华为·harmonyos
测试秃头怪13 小时前
python&selenium自动化测试实战项目详解
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
踏着七彩祥云的小丑13 小时前
Python——字符串常用操作
开发语言·python
阿钱真强道13 小时前
05 ComfyUI + SVD 系列(三):最小图生视频工作流拆解——节点含义、输入输出、参数作用与核心实验
python·aigc·stable-diffusion·svd·comfyui·工作流·图生视频
xcjbqd013 小时前
Python中Pandas如何将DataFrame写入MySQL_使用to_sql函数
jvm·数据库·python
蓝色的杯子13 小时前
Python面试30分钟突击掌握-LeetCode3-Linked list
python·leetcode·面试
ZC跨境爬虫13 小时前
海南大学交友平台开发实战 day10(后端向前端输出_前端读取数据全流程联调+日志调试落地)
前端·python·sqlite·html·状态模式