함수를 정의해야합니다. vowelCount()
. 입력은 단어 목록이고 나는 3 개의 키를 반환하는 사전을 반환해야합니다. 그것들은 모음보다 자음이 많은 단어를 포함하는 '자음'과 같은 모음을 가진 '모음이 많을수록'과 '양 모음'이 같은 '모음 모음'입니다. 그것은 DICT 더 속성 '추가'파이썬 def vowelCount() 사전을 생성합니다.
I가 없음을 sating 속성의 오류가 말을,
def voewlCount(wordList):
myDict = {}
vowelList = 'AEIOUaeiou'
contents = wordList.split()
for word in wordsList:
if vowelList in wordList == word:
myDict.append('half vowels')
elif vowelList in wordList > word:
myDict.append('more vowels')
else:
myDict.append('mostly consasants')
내가 쉘을 실행할 때 오류 메시지가 점점 오전 : 여기
지금까지 내 코드입니다 나는 아직도 문제가 있어요 내 코드를 수정하지만 ... 여기 내 새로운 코드가 도움def vowelContent(wordList):
myDict = {'more consonants':[],'more vowels':[],'half vowels':[]}
vowels = 'aeiouAEIOU'
for word in wordList:
if vowels in wordList < word:
myDict['more consonants'].append(word)
elif vowels in wordLists > word:
myDict['more vowels'].append(word)
else:
myDict['half vowels'].append(word)
return myDict
say = ['do', 'you','know','the','definition','of','insanity','or','being','insane'] print(vowelContent(say))
은 목록에서 모든 단어 위 여기 시작하는 데 도움이되는 몇 가지 프레임 워크 년대 'more consonants'
키
사전은 키/값 저장소와 같습니다. 사전에는 추가하지 않습니다. 사전에 항목을 추가하려면 다음과 같이 작성하십시오. myDict [ 'key'] = value – Rami