Python Object-Oriented Python Instant Objects Your first class

Michael Kaminski
Michael Kaminski
1,348 Points

I keep getting an error when I try to make a class called Student and an instance called me. Please help!

The instructions state: Now, make an instance of your class named me. Then print() out the name attribute of your instance.

I make a class called Student and then put in name="me", and then when I print it, I get an error saying it couldn't find me. I don't get it. Can someone give me a hint please?

first_class.py
class Student:
    name="me"
print(Student())

2 Answers

Scott Bailey
Scott Bailey
13,174 Points

The question is asking you to create an instance of the class Student - called "me"

me = Student()

This creates a new instance of Student called "me"

From there have a go at print the "name" of the new student (me)

Lucas Keown
Lucas Keown
7,614 Points

Hi Michael,

It looks like it's asking you to create a class called Student, with your name as a string in the name attribute. After that, it wants you to create an instance of Student called

me = Student()

Then you can print with

print(me.name)