My python code is as follows :
class Student():
def __init__(self, name, branch, year):
self.name = name
self.branch = branch
self.year = year
# Variables name,branch and year are instance variables
# Different objects like Student1, Student2 will have diff values of these variables.
print('Student object is created for Student : ', name)
def print_details(self):
print('Name:', self.name)
print('Branch:', self.branch)
print('Year:', self.year)
Stud1 = Student('AAkash','ECE',2015)
Stud2 = Student('Vijay','IT',2017)
Stud1.print_details()
Stud2.print_details()
My output is :
('Student object is created for Student : ', 'AAkash')
('Student object is created for Student : ', 'Vijay')
('Name:', 'AAkash')
('Branch:', 'ECE')
('Year:', 2015)
('Name:', 'Vijay')
('Branch:', 'IT')
('Year:', 2017)
whereas in my required output, i want statements like :
Name : AAkash
Branch : CSE