华为机考入门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 软件工程小施同学

相关推荐
Zane199411 分钟前
你以为的性能瓶颈,未必是真的瓶颈:用 cProfile 找到真凶
后端·python
铁手飞鹰35 分钟前
VSCode Python .embed 嵌入式环境黄色波浪线问题
ide·vscode·python
辰辉创聚37 分钟前
重组蛋白表达不出来怎么办?蛋白表达失败、低表达及异常原因解析
python·oracle·eclipse·重组蛋白·蛋白·western blot
淼澄研学1 小时前
基于Docker与iptables的AI智能体网络隔离实操指南
开发语言·python
量化吞吐机1 小时前
程序员学量化开发,先用示例拆清结构
人工智能·python
夜雨声烦丿2 小时前
从需求到页面:日期计算器应用的 ArkTS 原生实现
开发语言·javascript·华为·harmonyos
星辰徐哥2 小时前
打破社媒营销信息差:具身交互智能打造全自动化KOL情报体系
运维·python·自动化·交互·react·数字人
weixin_489690022 小时前
训练素材数据转变过程
人工智能·python
测试19982 小时前
UI自动化测试:窗口截图&文件上传实战
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
叫我:松哥2 小时前
基于Flask的教师评教管理系统,支持学生和教师两种角色登录
数据库·后端·python·数据挖掘·flask