我正在读我的教科书,我很困惑vowels_in_word =“”的重要性呢?我不确定它的意义。它只是持有char的值吗?另外,在创建for
循环时,char是什么?即使程序中的任何地方没有分配,你也可以分配你自己的变量吗?我正在读我的课本,我很困惑vowels_in_word =“”的重要性呢?
def get_vowels_in_word(word):
vowel_str = "aeiouy"
vowels_in_word = ""
for char in word:
if char in vowel_str:
vowels_in_word += char
return vowels_in_word
这意味着vowels_in_word变量被初始化为空。代码是在单词 – Illusionist
中查找元音for循环一次迭代单词一个字符(char) – Illusionist
[无法理解循环Python](http://stackoverflow.com/questions/19257862)/cant-understand-for-loops-python) –