Does anyone know how to fis this NameError?

I came across an NameError in line 14 that said that it couldnt defined: def_init. I guess because in the tutorial that I was watching it was a long line underscore, but i couldnt make it like very long like in the tutorial.
I will add my code here under and then the image of the tutorial that i was watching.

import os
import random

#Import the Turtle module
import turtle
turtle.fd(0)
turtle.speed(0)
turtle.bgcolor("black")
turtle.ht()
turtle.setundobuffer(1)
turtle.tracer(1)

class Sprite(turtle.Turtle):
    def_init_(self, spriteshape, color, startx, starty)
    turtle.Turtle._init_(self,shape = spriteshape)
    self.speed(0)
    self.penup()
    self.color(color)
    self.goto(startx, starty)
    self.speed = 1

#Create my sprites
player = Sprite("triangle", "white", 0, 0)

Below the image of the tutorial:

Hi @amel8star !
It should have 2 undersscores before and after the init.
Hope this helps!

def __init__(): # _ _init_ _

Also a space between def and __init__.

Yes, I know it must include the 2 undersscores but it didnt give me two. It gave me like two lines but with a little space in between and not a straight line.

It give mes like this __, it look likes this lines are not attached with each other if you see it close up.

@amel8star You need to add a space in between def and __init__,as @Firepup650 Said.

I did, but still did get the error.
See code below:

import os
import random

#Import the Turtle module
import turtle

#Show the window
turtle.fd(0)
#Set the animations speed to the maximum
turtle.speed(0)
#Change the background color
turtle.bgcolor("black")
#Hide the default turtle (=hiding the default turtle
#This saves memory
turtle.ht()
turtle.setundobuffer(1)
#This speeds up drawing
turtle.tracer(1)

class Sprite(turtle.Turtle):
    def__init__(self, spriteshape, color, startx, starty)
    turtle.Turtle._init_(self,shape = spriteshape)
    self.speed(0)
    self.penup()
    self.color(color)
    self.goto(startx, starty)
    self.speed = 1

#Create my sprites
player = Sprite("triangle", "white", 0, 0)

You need to have a space there:

def __init__

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