-1
我只學習了Python 1周。這是我的代碼:Python中嵌套的「for」循環 - 相同的循環但不工作 - 海龜
def board():
colorA=input("Please choose a first color for the CheckerBoard: ")
colorB=input("Please choose a second color for the CheckerBoard: ")
size=int(input("Please choose a box size: "))
num=int(input("Please choose a side length for the board: "))
x=-250
y=250
c=colorA
x=-250
for num in range(num):
y=y-size
for num in range(num):
Fbox(x,y,size,c)
x=x+size
if(c==colorA):
c=colorB
elif(c!=colorA):
c=colorA
它只是幾乎忽略了第一個「for」循環。
爲了理智,不要爲相同目的重複使用相同的變量。 – user2864740
對不起....我剛開始。 – user3838965