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

相关推荐
梅雅达编程笔记3 小时前
编程启蒙|Scratch 转 Python 系列第9天:字典/哈希表积木双向对照(AI大模型参数配置表实战)
开发语言·人工智能·python·numpy·pandas
条tiao条4 小时前
Navigation页面跳转教学博客
ui·华为·harmonyos·鸿蒙·页面跳转
zhz52144 小时前
GIS项目中空间参考转换与MBTiles偏移:问题成因、解法与避坑
python·vue·gis
ZZZMMM.zip4 小时前
竞品分析框架-基于鸿蒙的AI竞品分析应用开发实践
人工智能·华为·harmonyos·鸿蒙系统
KaMeidebaby5 小时前
卡梅德生物技术快报|如何制备单克隆抗体:小众禽类靶点单抗制备实操流程:双载体抗原交叉筛选完整工艺记录
人工智能·python·深度学习·算法·机器学习
乱写代码5 小时前
Pydantic学习--BaseModel
python
fu15935745685 小时前
【边缘计算实战】P1:从零搭建边云任务卸载仿真实验台(Python 可复现)
数据库·python·边缘计算
ldsweet5 小时前
《HarmonyOS技术精讲-Basic Services Kit》账号管理:应用内账号创建与管理
华为·harmonyos
蜡台6 小时前
通过Gradle脚本声明更改Java变量
android·java·开发语言·python·kotlin·gradle·groovy
智能体与具身智能6 小时前
TVA 本质内涵与核心特征(系列)
人工智能·python·智能体视觉