repl.it
@NihalAnand/

class demo

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class car:
	def __init__(self, color, model):
		self.color = color
		self.model = model
	def showProps(self):
		print("Color: " + self.color)
		print("Model: " + self.model)

cars = []
c1 = car("Orange", "Model S")
c2 = car("Yellow", "Model 3")
c3 = car("Blue", "Model X")
c4 = car("White", "Model Y")

cars.append(c1)
cars.append(c2)
cars.append(c3)
cars.append(c4)

for c in cars:
	c.showProps()
Fetching token
?