CLASS
-
[python] class instance의 변수로 정렬하기programming 공부/Python 2021. 5. 2. 15:52
게임 캐릭터를 만든다 생각하고 캐릭터를 만들어보자 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 class charactor(object): def __init__(self,id,name,hp,mp,power): self.id = id self.name = name self.hp = hp self.mp = mp self.power = power a = charactor(id=1, name='minho', hp=300, mp=300, power=10) b = charactor(id=2, name='bonggu', hp=300, mp=200, power=80) cs 캐릭터 두개중에 power가 높은순으로 정렬하고 싶다면 어떻게 해야할까? 정말 간단하게 해결할 수 있다 1 2..