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

相关推荐
not coder4 分钟前
我给鸿蒙原生 OFD 阅读器加了手写签批:手写笔防误触、矢量笔迹、批注追溯
华为·harmonyos·arkts·ofd
圆圆讲门店25 分钟前
实体获客团队|基础概念与核心要点整理
人工智能·python
砚底藏山河44 分钟前
【量化纯GET实战 #04】批量快照:一次 HTTP GET 取多只股票
java·python·金融·eclipse
烂蜻蜓1 小时前
Flask入门教程(九):模板渲染——用Jinja2构建动态页面
后端·python·flask
2601_966871401 小时前
AE影视后期特效-遮罩/调色/抠像/MG动画/3D/Vlog制作(完结)jzit
python
circuitsosk1 小时前
大模型本体安全防护实践:提示词注入防御、输出合规过滤与敏感信息脱敏
python·安全·数据脱敏·纵深防御·提示词注入·llmsecurity
Magic-ZYJ2 小时前
HarmonyOS 页面生命周期完整梳理:aboutToAppear、onPageShow、onPageHide 别再混着用
华为·ts·harmonyos·移动应用开发·arcts·arcui
工业一体机老司机2 小时前
Python实现工业一体机Modbus-TCP通信-从协议解析到多设备轮询实战
开发语言·python·tcp/ip
2401_885885042 小时前
国际语音php接口代码示例:PHP使用cURL快速调用语音发送API
android·开发语言·前端·人工智能·python·php·语音识别
lilian2332 小时前
HarmonyOS 7 新特性(五)|ContainerReader 容器断点与自适应布局
前端·华为·harmonyos