【发布时间】:2015-05-19 14:08:09
【问题描述】:
vowels = 'aeiou'
# take input from the user
ip_str = raw_input("Enter a string: ")
# make it suitable for caseless comparisions
ip_str = ip_str.casefold()
# make a dictionary with each vowel a key and value 0
count = {}.fromkeys(vowels,0)
# count the vowels
for char in ip_str:
if char in count:
count[char] += 1
print(count)
错误:
Line - ip_str = ip_str.casefold()
AttributeError: 'str' object has no attribute 'casefold'
【问题讨论】:
标签: python python-2.6 case-folding