но если отдельно прописать для какого-нибудь объекта tell, но None нету( t.tell() к примеру )
t = Teacher('Nina Petrovna', 50, 30000)
t.tell()
t = Teacher('Nina Petrovna', 50, 30000)
print(t.tell())
Я понимаю, что в методе отсутствует return, от этого и None вылезает
tell()
возвращает None, вы этот None и выводите на экран. Вы явно запутались с print/return. Для вашей реализации вам не нужно делать print(obj.tell())
, потому что нужные принты вы вызваете в самом методе.for member in members:
member.tell()
def tell(self):
return 'Имя {}, возраст {}'.format(self.name, self.age)
s = Students('Carl', 20, 80)
s.tell()
s = Students('Carl', 20, 80)
print(s.tell())
# либо
s = Students('Carl', 20, 80)
resutl = s.tell()
print(result)
Надо вернуть что-то типа "введена не та команда".
// makeslicecopy allocates a slice of "tolen" elements of type "et",
// then copies "fromlen" elements of type "et" into that new allocation from "from".
// makeslicecopy allocates a slice of "tolen" elements of type "et",
// then copies "fromlen" elements of type "et" into that new allocation from "from".
func makeslicecopy(et *_type, tolen int, fromlen int, from unsafe.Pointer) unsafe.Pointer {
var tomem, copymem uintptr
if uintptr(tolen) > uintptr(fromlen) {
var overflow bool
tomem, overflow = math.MulUintptr(et.size, uintptr(tolen))
if overflow || tomem > maxAlloc || tolen < 0 {
panicmakeslicelen()
}
copymem = et.size * uintptr(fromlen)
} else {
// fromlen is a known good length providing and equal or greater than tolen,
// thereby making tolen a good slice length too as from and to slices have the
// same element width.
tomem = et.size * uintptr(tolen)
copymem = tomem
}
var to unsafe.Pointer
if et.ptrdata == 0 {
to = mallocgc(tomem, nil, false)
if copymem < tomem {
memclrNoHeapPointers(add(to, copymem), tomem-copymem)
}
} else {
// Note: can't use rawmem (which avoids zeroing of memory), because then GC can scan uninitialized memory.
to = mallocgc(tomem, et, true)
if copymem > 0 && writeBarrier.enabled {
// Only shade the pointers in old.array since we know the destination slice to
// only contains nil pointers because it has been cleared during alloc.
bulkBarrierPreWriteSrcOnly(uintptr(to), uintptr(from), copymem)
}
}
if raceenabled {
callerpc := getcallerpc()
pc := funcPC(makeslicecopy)
racereadrangepc(from, copymem, callerpc, pc)
}
if msanenabled {
msanread(from, copymem)
}
memmove(to, from, copymem)
return to
}
const rCount = Array.prototype.reduce.call(str, (acc, letter) => {
if (rX.includes(letter)) {
acc.X++;
} else if (rO.includes(letter)) {
acc.O++;
}
return acc;
}, { X: 0, O: 0 });
const rCount = Array.prototype.reduce.call(str.toLowerCase(), (acc, letter) => {
switch(letter) {
case 'x':
acc.X++;
break;
case 'o':
acc.O++;
break;
}
return acc;
}, { X: 0, O: 0 });