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

相关推荐
2601_9516437711 分钟前
Python第一,Java跌出前三,C语言杀回来了
java·c语言·python·编程语言排行·技术趋势
AC赳赳老秦2 小时前
OpenClaw+Power Apps 实战:自动生成 Power Apps 应用、连接 Excel 数据源
大数据·开发语言·python·serverless·excel·deepseek·openclaw
hahjee4 小时前
【鸿蒙PC】KCP应用集成:AtomCode驱动NAPI全流程
华为·harmonyos
茉莉玫瑰花茶4 小时前
综合案例 - AI 智能租房助手 [ 5 ]
服务器·数据库·人工智能·python·ai
风华圆舞4 小时前
解析鸿蒙 SpeechRecognitionPlugin:从权限申请到识别回调的完整链路
华为·harmonyos
文艺倾年4 小时前
【强化学习】强化学习基本概念,20W字总结(一)
人工智能·python·语言模型·自然语言处理·面试·职场和发展·大模型
木咺吟4 小时前
鸿蒙原生应用实战(一):塔罗牌占卜App开发 — 环境搭建与首页开发
华为·harmonyos
宸丶一4 小时前
Day 13:持久化记忆 - 让 Agent 拥有长期记忆
jvm·python·ai
祭曦念4 小时前
【共创季稿事节】鸿蒙ArkTS图片插值布局实战
华为·harmonyos
码云骑士4 小时前
13-列表append的底层真相(上)-listobject源码中的预分配策略
开发语言·python