I defined a class in try.py
try.py
class student:
def __init__(self, name, major, gpa, is_on_probation):
self.name = name
self.major = major
self.gpa = gpa
self.is_on_probation = is_on_probation
Now i created new file in same directory. class.py
class.py
from try import student
student1 = student("Jimmy", "Business", 3.1, False)
print(student1.name)
Output
C:\Users\User\PycharmProjects\test\venv\Scripts\python.exe C:/Users/User/PycharmProjects/test/try.py
Process finished with exit code 0
PROBLEM
The print statement does not produce any result. I'm new to both python and stack overflow. I searched and couldn't find a solution. So I'm posting this.
tryandclassare reserved keyword, thus it will result in a syntax error. Please renametry.pyandclass.pyto a different name to avoid this issue. Also, running what you currently named astry.pyproduce no output because it only defined a classstudentand immediately exit.