I have tried to create a program to store some datum of students. I want to create a function that ask the user to input the name and gpa of the student and create an object of that student. I have entered Amy as the name. But I am facing an error saying that the "Amy" is not defined.
class student:
#Constructor
def __init__(self, name, gpa):
self.name = name
self.gpa = gpa
#Method
def get_info(self):
return self.name, self.gpa
def add_student():
name = input("Please enter a student name: ")
gpa = input("Please enter the gpa of {a}: ".format(a = name))
print("{a} with gpa {b} is saved in the database.".format(a = name, b = gpa))
name = student(name, gpa)
def print_info(name):
c, d = name.get_info()
print("Name: {a} GPA: {b}".format(a = c, b = d))
add_student()
print_info(Amy)
Please help! How can I get the user input and create an object with those info and get the ability to print the info with a function. Any help will be highly appreciated.