understand this error AttributeError Turtle object has no attribute Listen Any ideas

+1 vote

this is my code

import turtle
import random
from turtle import *

m = turtle.Turtle()
m.speed(0)
m.width(7)

def go_up():
    if head.direction != "down":
        head.direction = "up"

def go_down():
    if head.direction != "up":
        head.direction = "down"

def go_left():
    if head.direction != "right":
        head.direction = "left"

def go_right():
    if head.direction != "left":
        head.direction = "right"

def move():
    if head.direction == "up":
        y = head.ycor()
        head.sety(y + 20)

    if head.direction == "down":
        y = head.ycor()
        head.sety(y - 20)

    if head.direction == "left":
        x = head.xcor()
        head.setx(x - 20)

    if head.direction == "right":
        x = head.xcor()
        head.setx(x + 20)

m.Listen()
m.onkeypress(go_up, "w")
m.onkeypress(go_down, "s")
m.onkeypress(go_left, "a")
m.onkeypress(go_right, "d")
May 20, 2020 in Python by MOHAMMED
• 130 points

edited May 20, 2020 by Gitika 4,931 views

1 answer to this question.

0 votes

Hey, @Mohammed,

You are getting this error because you are trying to access an attribute or method that does not exist on the object.

Try to replace:

m.Listen()

With the following:

m.listen()

Since python is case sensitive, "Listen" and "listen" makes a difference. Hence the error. 

I hope this will omit your error.

answered May 20, 2020 by Gitika
• 65,910 points

Related Questions In Python

0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'mainloop'" python module turtle

Hey @Nagya, replace  wn.mainlopp() with turtle.mainloop() ...READ MORE

answered Jun 19, 2019 in Python by Faiza
6,421 views
+1 vote
3 answers

Python error "AttributeError: 'Turtle' object has no attribute 'Shape'"

Hey @Nagya, replace python.Shape("Square") with the following: python.shape("square") Python is case ...READ MORE

answered Jun 19, 2019 in Python by Faiza
20,972 views
0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,560 points
8,892 views
0 votes
2 answers

Python Pandas error: AttributeError: 'DataFrame' object has no attribute 'rows'

Try this: data=pd.read_csv('/your file name', delim_whitespace=Tru ...READ MORE

answered Dec 10, 2020 in Python by anonymous
• 82,880 points
129,808 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,007 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,386 views
0 votes
1 answer

Error: wn = trtl.Screen() AttributeError: 'Turtle' object has no attribute 'Screen

Hi, @There, It requires a very simple hack ...READ MORE

answered Nov 3, 2020 in Python by Gitika
• 65,910 points
2,315 views
0 votes
1 answer

Getting error "AttributeError: 'Screen' object has no attribute 'title' on line 8"

Hey @TedTickles,  Replace  wn.update() with turtle.up ...READ MORE

answered Dec 24, 2020 in Python by Gitika
• 65,910 points
3,429 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP