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

相关推荐
Java患者·2 分钟前
《Python 人脸识别入门实践:从人脸检测到人脸比对完整实现》
开发语言·python·opencv·目标检测·计算机视觉·目标跟踪·视觉检测
宸丶一11 分钟前
Day 10:LangGraph - Agent 的图执行引擎
java·windows·python
weixin_3077791318 分钟前
Python写入Shell文件使用Linux系统的换行符
linux·开发语言·python·自动化
zmzb010337 分钟前
Python课后习题训练记录Day130
开发语言·python
nashane38 分钟前
HarmonyOS 6学习:深入解析冷启动中的ArkCompiler
学习·华为·harmonyos
高洁011 小时前
医疗行业的数字孪生革命
python·机器学习·数据挖掘·transformer·知识图谱
MATLAB代码顾问1 小时前
Python Pandas数据分析入门指南
python·数据分析·pandas
风满城332 小时前
【鸿蒙原生应用开发实战】第四篇:相册与提醒——AlbumPage + ReminderPage 完整实现
华为·harmonyos
风之所往_2 小时前
Python 3.6 新特性全面总结
python
abcy0712132 小时前
flask celery hdfs 异步上传
python·hdfs·flask