is counter has certain value inside a class in python
- by mazlor
i am learning classes in python and when i was reading the documentation i found this example that i didn't understand :
class MyClass:
"""A simple example class"""
def __init__(self):
self.data = []
i = 12345
def f(self):
return 'hello world'
then if we assign :
x = MyClass()
x.counter = 1
now if we implement while loop :
while x.counter < 10:
x.counter = x.counter * 2
so the value of x.counter will be :
16
while for example if we have a variable y :
y = 1
while y < 1 :
y = y *2
then if we look for the value of y we find it
1
so i don't know how is the value of counter became 16 .
thanks