- Messages
- 134
- Reaction score
- 0
- Points
- 26
how can i change the values of the xAxis and the yAxis because what I'm having as an output are only zeroes.
Code:
#I want to have a result like this:
Car: Red xAxis: 10 yAxis: 50
Car: Yellow xAxis: 20 yAxis: 40
Car: Green xAxis: 30 yAxis: 30
Car: Blue xAxis: 40 yAxis: 20
Car: White xAxis: 50 yAxis: 10
class Car():
def __init__(self,color):
self.color = color
self.xAxis = 0
self.yAxis = 0
def moveUp(self):
self.yAxis+=1
def moveRight(self):
self.xAxis+=1
CarColor = ['Red','Yellow','Green','Blue','White']
CarList = []
for eachColor in CarColor:
CarList.append(Car(eachColor))
for eachCar in CarList:
print("Car:",eachCar.color,end=' ')
print("xAxis:",eachCar.xAxis,end=' ')
print("yAxis:",eachCar.yAxis,end='\n')