Most people have difficulties to understand classes,
little warriors you're not alone. In this post, I'll try to teach you, how to understand class and apply it in your life!
class Drinks: kind = "Drink" def __init__(self,name): self.name=name one = Drinks("Orange juice") two = Drinks("coca-cola") three = Drinks("water") print(two.kind) print(two.name)
- You create the class variable kind to share the attribute.
- We use the init to initialize the instance.
- name its an attribute of an object.
- And all immutable objects: one, two, and three.
Thanks for reading! ;))