나는 간단한 Simon이 게임을 완성했다고 말했습니다. 내 문제는 IDLE 3.4는 내가 무엇인지 알 수 없을 때 문제가 있다고 말합니다. (A 연습과)무엇이 문제입니까?
내 코드 :
#Simple pattern repeating game
#Randomly chooses a pattern then user has to repeat
import random
poss = [int(1), int(2), int(3), int(4)]
#Sets possible choices
pattern = []
#Sets an array for the pattern to be contained in
plyr = []
#Sets an array for the players pattern to be contained in
def game():
#Makes a function for the game to be played
pattern.append(random.choice(poss))
#Adds a new value to the game pattern every time
for i in pattern:
#Loops through the pattern
print(i)
#Prints the pattern you need to copy
#For testing it sticks but this is to be change
for i in pattern :
#Loops through the pattern so you can give your value
plyr[i] = int(input("Pattern part " + (i + 1) + " is?")
#Gets your input of that value in the pattern
if(plyr == pattern):
#Checks if your pattern is right
game()
#Continues the game
내 문제가 if
문에있다, 그것은 콜론 (:)이 잘못되었다는납니다.
문제가 무엇인지 아는 사람이 있습니까?
게임은 인수에 하나의 값만 추가합니다. 루프의 요점은 무엇입니까? –
@MalikBrahimi 첫 번째 루프는 "사이먼이 말하는 것"입니다. 두 번째 루프는 입력을받습니다. – Ashmoreinc
네, 패턴에 하나의 값만 추가합니다. –