I am new to python and this question has been asked before
but i have a different situation, this is my program
class student:
def address(self):
print('address is mumbai')
def contact(self):
print('email : foo@yahoo.com')
def main(self):
_student=student()
_student.address()
_student.contact()
if __name__ == "__main__":
main()
i dont know if it is my indentation that is causing problem or it has something to do with the scope of the method
main
is a method inside of the class student
, so you need to change where main
is defined.
class student:
def address(self):
print('address is mumbai')
def contact(self):
print('email : foo@yahoo.com')
def main():
_student=student()
_student.address()
_student.contact()