In python NameError: name ‘screen’ is not defined. Did you mean: ‘Screen’? we face this error message when we import screen from turtle and convert screen variable [small s ] then we need to use value Screen [Capital S ] but we use screen [small s ] then the python interpreter shows this error message, If you want to fix this error you need to just remove screen [small s ] and type Screen [Capital S ], For more clarification, see the below example.
Wrong Code
import turtle
from turtle import Screen
screen = screen()
turtle.shape("turtle")
turtle.color("red")
# Step 2 set turtle starting position
turtle.penup()
turtle.goto(0, -100)
turtle.pendown()
turtle.pensize(5)
# Step 3 Draw a heart shape
turtle.begin_fill()
turtle.left(140)
turtle.forward(224)
turtle.circle(-112, 200)
turtle.setheading(60)
turtle.circle(-112, 200)
turtle.forward(224)
turtle.end_fill()
screen.exitonclick()
Error Massage
Traceback (most recent call last):
File "/home/kali/python/webproject/error/main.py", line 3, in <module>
screen = screen()
NameError: name 'screen' is not defined. Did you mean: 'Screen'?
Wrong code line
screen = screen()
Correct code line
screen = Screen()
- Wrong action: screen [small s ].
- Correct action: Screen [Capital S ].
Entire Correct Code line
import turtle
from turtle import Screen
screen = Screen()
turtle.shape("turtle")
turtle.color("red")
# Step 2 set turtle starting position
turtle.penup()
turtle.goto(0, -100)
turtle.pendown()
turtle.pensize(5)
# Step 3 Draw a heart shape
turtle.begin_fill()
turtle.left(140)
turtle.forward(224)
turtle.circle(-112, 200)
turtle.setheading(60)
turtle.circle(-112, 200)
turtle.forward(224)
turtle.end_fill()
screen.exitonclick()
What is NameError: name ‘screen’ is not defined. Did you mean: ‘Screen’?
In python we face this error message when we import the screen from turtle and convert the screen variable [small s ] then we need to use the value Screen [Capital S ] but if we use screen [small s ] then the python interpreter shows this error message.
How to fix NameError: name ‘screen’ is not defined. Did you mean: ‘Screen’?
If you want to fix this error you need to just remove screen [small s ] and type Screen [Capital S ], For more clarification, see the above example.
For more information Visit YouTube Channel.

