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

相关推荐
GEO_ai_zhijian4 分钟前
饮料生产线质量检测系统供应商哪家强
大数据·python
量化吞吐机1 小时前
近期量化工具怎么选,先看规则流程能否承接
人工智能·python
一世繁华行1 小时前
Python帧对象
python
w139548564222 小时前
双色叠加雷达图:DuetReport 双人对比
华为·harmonyos·鸿蒙系统
星释2 小时前
鸿蒙智能体开发实战:19.使用变量
华为·ai·harmonyos·鸿蒙·智能体
三川6982 小时前
Tkinter库的学习记录08- 容器控件
python
c_lb72882 小时前
近期AI量化工具选择,学习开发执行要分开
人工智能·python
b130538100492 小时前
鸿蒙实战:交互反馈动画 — 按压缩放效果
华为·交互·harmonyos·鸿蒙系统
拥抱太阳06162 小时前
HarmonyOS 应用开发《掌上英语》第5篇:依赖注入与全局状态:AppStorageV2 实战HarmonyOS 应用开发《掌上英语》第1篇
pytorch·华为·harmonyos
天天进步20152 小时前
Python全栈项目--校园食堂点餐与推荐系统
开发语言·python