The code works well, but you have an extra space on line def talk(self):
, which impacts the indentation of the code inside this function too.
It should be:
class Student:
def __init__(self):
self.name='Viraj'
self.age=17
self.dob=10-1-2003
def talk(self):
print("name-", self.name)
print("age-", self.age)
print("Date of Birth-", self.dob)
s1=Student()
print(s1.name)
s1.talk()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…