编写fib类,Fib(10)表示数列前10个元素,求len(Fib(10))这样写错误在哪里
class Fib(object):
def __init__(self, *num):
self.nums=num
def __len__(self):
return len(self.nums)
f = Fib(10)
print f
print len(f)
class Fib(object):
def __init__(self, *num):
self.nums=num
def __len__(self):
return len(self.nums)
f = Fib(10)
print f
print len(f)
2016-05-25
举报