I'm creating a practice python file to better understand object oriented programming and I am getting the following error:
AttributeError: type object 'ID' has no attribute 'the_other_number' I don't really understand why this happens because when I change the variable like below, it works just fine. I only receive an error when I try to use it in an if statement:
ID.the_other_number = 'new_value' Below is my example code that I am trying to fix, any help is appreciated.
class ID(): def __init__(self): self.other_number() pass def other_number(self): self.the_other_number = 3111 class ID_2(): def __init__(self): self.update_number() def update_number(self): if ID.the_other_number > 4: print(ID.the_other_number) if __name__ == '__main__': ID() ID_2() I was expecting it to understand what variable is equal to and run the if statement correctly. Also, don't try to make sense of the code, I realize the code doesn't make sense, it is simply an example.