我是python的初学者,并尝试使用list和for循环编写一个程序来查找字母是元音还是辅音
代码如下:
al=input("Enter the alphabet")
list=['a','e','i','o','u']
for p in list:
if al==p:
print("The alphabet is a vowel")
else:
print("The alphabet is a consonant")
输出为:
C:\ Users \ dell \ PycharmProjects \ HelloWorld \ venv \ Scripts \ python.exe
C:/Users/dell/PycharmProjects/HelloWorld/app.py
输入字母]
退出代码为0的处理完成
有人可以告诉我我要去哪里哪里
我是python的初学者,并尝试使用list和for循环编写一个程序来查找字母是元音还是辅音。代码如下:al = input(“ Enter the Alphabet”)list = ['a', 'e'...
有四个问题:
else
不能按照您认为的方式工作。仅当没有break
退出循环时才执行。 (请注意,它附加到for
循环,而不是if
语句。)
al=input("Enter the alphabet")
list=['a','e','i','o','u']
if al in list:
print("The alphabet is a vowel")
else:
print("The alphabet is a consonant")