2014-12-03 3 views
-1

오류가없는 것으로 보이는 구문 오류가 계속 발생합니다. 그것은 and와 비교를 가진 if 문 내에서 발생하며 이유는 확실하지 않습니다. 이것은 또한 파이썬을 사용하는 나의 첫 번째 학기이므로 도움을 주시기 바랍니다. 가져 오기에, "/Cosc-151/Assignment5/a5_v34.py E", 라인 1 파일 : 파이썬 스크립트에서 구문 오류가 발생합니다.

while userWins < 2 or CPUWins < 2: 
    answer = random.randrange(3) 
    print(str(answer)) 
    print("[1]-- Rock") 
    print("[2]-- Paper") 
    print("[3}-- Scissors") 
    guess = int(input("Enter a number corresponding to a choice.") 
    if guess == 1 and answer == 3: #<--This is the line that keeps getting the syntax error 
     userWins = userWins + 1 
     print(name, " wins that round") 
     RoundScore(userWins, CPUWins, name) 
    elif guess == 1 and answer = 2: 
     CPUWins += 1 
     print(name, " loses that round") 
     RoundScore(userWins, CPUWins, name) 

은 IDLE 나에게

역 추적 (가장 최근 통화 마지막)를 제공하는 오류입니다 개조 파일 "E/COSC-151/Assignment5 \ Mods.py"라인 61 경우 추측 == 1 응답 == 3 ^ 구문 에러 잘못된 구문

감사

+2

많은이 필요하기 전에, 실제 오류는 이전 행에 있습니다. 이 경우에 당신이없는 것 같아요 ')' – Aaron

답변

3

이전 줄에 닫는 괄호가 없습니다 (int 호출 닫기). 라인에

당신이 구문 오류를 얻을 때 배의

guess = int(input("Enter a number corresponding to a choice.")) 
                  ^
                 You forgot this