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

相关推荐
RSABLOCKCHAIN8 小时前
AI Agents in LangGraph-2
人工智能·python
爱写代码的阿森8 小时前
鸿蒙三方库 | harmony-utils之EncryptUtil AES对称加密详解
华为·harmonyos·鸿蒙·huawei
爱写代码的阿森8 小时前
鸿蒙三方库 | harmony-utils之FileUtil文件管理与目录详解
华为·harmonyos·鸿蒙·huawei
WA内核拾荒者8 小时前
WhatsApp 账号异常检测的自动化告警系统设计
数据库·python·自动化
码流怪侠9 小时前
【GitHub】Bend:让 GPU 并行编程像写 Python 一样简单
python·github
爱写代码的森10 小时前
鸿蒙三方库 | harmony-utils之DateUtil日期计算详解
华为·harmonyos·鸿蒙·huawei
2401_8949155310 小时前
GEO 搜索优化完整源码从零部署:环境配置、集群搭建全流程
开发语言·python·tcp/ip·算法·unity
youtootech11 小时前
HarmonyOS 6.0 长按菜单与拖拽预览
华为·harmonyos
zhiSiBuYu051712 小时前
Python3 模块开发与应用实战指南
python