Python for beginners 4 hours program

So I’m a beginner beginner in Python and I’ve been watching freecodecamp’s python for beginners 4-hour video. I’m doing this to go on to take the data analysis with python course. Anyways I’m at the point where the teacher shows us how to create classes and objects. I’m putting the exact same code into my Pycharm but it doesn’t seem to recognize what I’m typing in and it doesnt create a long underscore like his does in the video. I’m using a different version of Python than his though, mine is Python 3.11.

Here’s the code:

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

Here’s the point in the video that talks about this:
https://youtu.be/rfscVS0vtbw?list=PLWKjhJtqVAbnqBxcdjVGgT3uVR10bzTEB&t=13436

In my Pycharm, the double underscores are broken and the code in general in the app file keeps bringing up errors. The code also isn’t indenting the same way as it does in the instructor’s video.

You need a space between def and the __init__.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.