简体   繁体   中英

Got a error with turtle in Python. turtle.Turtle

I started to program a few days ago and today I've tried to do the game 'Pong' using python. But since I am a beginner I can't find what is wrong with the code or something. When I try to create a turtle.Turtle, the Pycharm says the code is unreachable.

    # Game Pong

import turtle

wn = turtle.Screen()
wn.title("Quarentena 21/03")
wn.setup(width=800, height=600)
wn.bgcolor("black")
wn.tracer(0)

# Main Game Loop
while True:
    wn.update()

# Paddle A
paddle_a = turtle.Turtle()
paddle_a.shape("square")
paddle_a.speed(0)
paddle_a.color('green')
paddle_a.penup()

Yes, the code is unreachable. Unless you put something to break the loop, 'while True' continues forever because the default condition is always True unless you set it to false. So you can't reach the code below the loop. Happy programming! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM