So I made a class named Courses and now I want to create a variable that holdes this class depending on user input. For example:
varName = input("Enter name of Course")
class Course:
def __init__(self , _Name, _ID, _digitsec, _studentnum, _capacity , _secnum):
self.Name = _Name
self.ID = _ID
self.digitsec = _digitsec
self.studentnum = _studentnum
self.capacity = _capacity
self.secnum = _secnum
now I want :
somevariablehere = Course(Name, ID, digitsec, studentnum, capacity, secnum)
and I want this variable to be called whatever the user said in varName input.
this is my full code:
while True:
Name = input("Enter course name:")
ID = input("Enter course ID:")
capacity = input("Enter course capacity(Not per section):")
secnum = input("Enter how many sections are possible:")
studentnum = input("Enter number of students demanding:")
digitsec = input("Enter how many digits each section should have(1 to 4):")
class Course:
def __init__(self , _Name, _ID, _digitsec, _studentnum, _capacity , _secnum):
self.Name = _Name
self.ID = _ID
self.digitsec = _digitsec
self.studentnum = _studentnum
self.capacity = _capacity
self.secnum = _secnum
coursenameID = str(Name) + str(ID)
somevariablehere = Course(Name, ID, digitsec, studentnum, capacity, secnum)
In this case I want somevariablehere to be equal to the "Name" the user specified in the "Name" input.