0

Why does it show 122 but not 123 when printing this code(hmp)???

class Hg: a=0 def __init__(self): Hg.a += 1 def __del__(self): Hg.a -= 1 a=Hg() print(a.a) b=Hg() print(b.a) a=Hg() print(a.a)

27th Jun 2021, 2:01 AM
TCorn
TCorn - avatar
1 Odpowiedź
+ 1
TCorn you have defined object a twice
27th Jun 2021, 2:24 AM
Shahghasi Adil
Shahghasi Adil - avatar