简体   繁体   中英

Why doesn't `if` work in Python Turtle , it seems to me I wrote everything correctly

import turtle
turtle.color ("black", "red")
turtle. speed (10)
while True:
    a = input("введите действие (вперед-w, назад-s, влево-a, направо-d):"))
    if a == "w":
        u = int(input("насколько?:"))
        turtle.forward (u)

enter image description here

if does not work in Python turtle, please help

Почему в Python turtle не работает "IF"?

The initial problem is this line:

а = input("..."))

You have one too many closing parentheses. Try not to confuse the parentheses inside the quotes and the ones outside. Running your code should have produced an error:

SyntaxError: unmatched ')'

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