我试过寻找答案,但似乎没有任何帮助.我弄完了:
def noVowel(s):
'return True if string s contains no vowel, False otherwise'
for char in s:
if char.lower() not in 'aeiou':
return True
else:
return False
Run Code Online (Sandbox Code Playgroud)
无论字符串如何,它总是返回True.
我有以下代码:
class Stat(list):
def __init__(self, lst = []):
self.s = list(lst)
def __repr__(self):
return "Stat({})".format(self.s)
def add(self, item):
self.s.append(item)
def len(self):
return len(self.s)
...(more methods, but not necessary)
Run Code Online (Sandbox Code Playgroud)
所有方法都能正常工作但是len().无论Stat对象的长度如何,返回的长度始终为0; 我不明白为什么.