class ElectricCar:
def __init__(self, name,battery):
self.name = name
self.battery = 100
def drive(self,dist):
self.dist = dist
for i in range(1,self.dist):
self.battery -= 1
if self.battery <= 0:
print("주행 불가")
break
car = ElectricCar("테슬라",120)
car.drive(120)
print(f"남은 배터리: {car.battery}")
To embed this project on your website, copy the following code and paste it into your website's HTML: