Quick actions

cmd+k|ctrl+k

Navigation

Languages

Creating Our Own Objects

Snippet info

Language

Python

Visibility

public

Author

fpuleano

Created

2023-03-31T18:16:05.405826Z

Updated

2023-04-18T13:21:45.490808Z

class PlayerChar:
    def __init__(self, name, age):
      self.name = name #attributes
      self.age = age
    
    def run(self):
      print('run')
        
player1 = PlayerChar('Cindy', 44)
player1.attack = 75
player2 = PlayerChar('Thomas', 27)
player3 = PlayerChar('Bobbi', 32)
print(player1.name)
print(player1.age)
print(player2.name)
print(player2.age)
print(player3.name)
print(player3.age)

print(player1.attack)

print(player1)
print(player2)
print(player3)
INFO