出於某種原因,這給了我一個無效的語法錯誤在所有定義的函數(以及它們),我真的很困惑的幫助。我不知道什麼是錯的,所以任何幫助對我都會有所幫助,非常非常感謝你。未知的錯誤與我的代碼
代碼:
from turtle import*
x=0
y=0
#by importing using 'from' lets you minimise the need to write turtle.forward
"""
forward (50) # moves the turtle forward 50 steps
right (90) # turns the turtle to the right 90 degress
pencolor("red") # sets the pencolor. Needs to be written before drawing the shape
fillcolor("blue") #always needs to be written before begin fill
fillcolor("#FF0000") #fills with a hexadecimal color
colormode(255) #changes the color fill option to use 0-255 rather than values from 0-1.
fillcolor(0,255,0) #shows how to use R G B values (to fill with red in this case)
begin_fill() #needs to be written before you begin drawing a shape
end_fill() #needs to be written after you have finished drawing a shape
pensize(10) # needs to be used before giving draw commands
penup() # allows the turtle to be moved to other locations without drawing
bgcolor("orange") # fills the background of the whole drawing canvas
pendown() # normally the pen is down from the start but you may need to use pendown after lifting the penup
speed(5) #from 0 to 10, 0 being the fastest. You need to specify the speed before writing the drawing instructions
done() # completes the drawing
"""
# start your code here
def turtleForward():
print("How far forward do you want to go?")
forward = input()
forward ((int(forward))
print("Want to go forward again? (y) (n)")
moreForward = input()
if moreForward == y:
turtleFoward()
def turtleRight():
print("How far right do you want to go?")
right = input()
right ((int(right))
print("Want to go right again? (y) (n)")
moreRight = input()
if moreRight == y:
turtleRight()
def turtleLeft():
print("How far left do you want to go?")
left = input()
left ((int(left))
print("Want to go left again? (y) (n)")
moreLeft = input()
if moreLeft == y:
turtleLeft()
def penColour():
print("What pen colour would you like?")
colour = input()
pencolor (colour)
def menu():
print("""Option 1. Set pen colour.
Option 2. Go forward.
Option 3. Go right.
Option 4. Go left.
Option 5. Quit.""")
optionChoice = input()
if optionChoice == '1':
pencolour()
elif optionChoice == '2':
turtleForward()
elif optionChoice == '3':
turtleRight()
elif optionChoice == '4':
turtleLeft()
elif optionChoice == '5':
x = 1
print("Hello. Welcome to the turtle program I have made.")
while x == y:
menu()
什麼意思? O.o – Flux
你可以粘貼完整的回溯? – smeso
它不會給回溯,只是彈出說無效的語法,併發送給我在我定義的函數中的所有我的第二個打印功能。 – Flux