0
How to use newline statement in print function? How to print the color of the object in next line in below code?
class Robot: def introduce_self(self): print("My name is " + self.name +" My color is "+ self.color) r1 = Robot() r1.name = "Tim" r1.color = " red" r1.weight = 30 r2 = Robot() r2.name = "Alice" r2.color = " blue " r2.weight = 65 r1.introduce_self() r2.introduce_self()
1 ответ
0
Just take one new print line inside the function, it'll print the statement in new line.
Like this:
print("My Colour is: " + self.color)