2016-10-12 1 views
-2

enter image description here올바른 출력

def interpret(result : [None]) -> str: 
    s = '' 
    s = s + 'Start state = ' + result[0] +'\n ' 
    for x in result[1:-1]: 
     s += ' Input = ' + x[0]+ '; new possible states = ' + str(sorted(x[1])) + '\n ' 
    s = s + ' Input = ' + x[0]+ '; new possible states = ' + str(sorted(result[-1][1])) + '\n' 
    s = s + 'Stop state(s) = ' + str(sorted(result[-1][1])) 
    return s 




      evaluated: Start state = start 
    Input = 1; new possible states = ['start'] 
    Input = 0; new possible states = ['near', 'start'] 
    Input = 1; new possible states = ['end', 'start'] 
    Input = 1; new possible states = ['start'] 
    Input = 0; new possible states = ['near', 'start'] 
    Input = 0; new possible states = ['end', 'start'] 
Stop state(s) = ['end', 'start'] == Start state = start 
    Input = 1; new possible states = ['start'] 
    Input = 0; new possible states = ['near', 'start'] 
    Input = 1; new possible states = ['end', 'start'] 
    Input = 1; new possible states = ['start'] 
    Input = 0; new possible states = ['near', 'start'] 
    Input = 1; new possible states = ['end', 'start'] 
Stop state(s) = ['end', 'start'] 

31 * 오류와 출력을 일치하지 않습니다. 문자열을 올바른 형식으로 반환해야합니다. 출력은 올바른 출력과 같지만 오류가 발생합니다. 누군가가 왜 그것이 옳지 않은지 말할 수 있습니까? 많은 감사 그런데

입력이 ['start', ('1', {'start'}), ('0', {'start', 'near'}), ('1', {'end', 'start'}), ('1', {'start'}), ('0', {'start', 'near'}), ('1', {'end', 'start'})]

하고 정확한 출력이 '= 주 시작 시작 "\ n 입력 = 1; 새로운 가능한 상태 ='시작 '] \ n 입력 = 0; 새로운 \ n 입력 = 1, 가능한 새 상태 = [ '시작'] \ n 입력 = 1, 가능한 새 상태 = [ '끝', '시작' 0, 새로운 가능한 상태 = [ '가까이', '시작'] \ n 입력 = 1, 새로운 가능한 상태 = [ '끝', '시작'] \ n 정지 상태 = [ '끝', '시작'] \ n "`

내가 얻은 결과를 보여주기 위해 그림을 추가했습니다.

+4

에 오신 것을 환영합니다을 SO. 당신은 당신이 요구하는 것을 이해할 수있는 충분한 정보를 제공하지 않았습니다. [Minimal, Complete, Verifiable example] (http://stackoverflow.com/help/mcve)를 제공해주십시오. 또한 [How to ask] (http://stackoverflow.com/help/how-to-ask)를 읽으십시오. – CAB

답변

0

나는 작동하는 것 같다있는 result[-1][0]x[0]에서 함수의 6 번째 라인을 변경했습니다 :

def interpret(result : [None]) -> str: 
    s = '' 
    s = s + 'Start state = ' + result[0] +'\n ' 
    for x in result[1:-1]: 
     s += ' Input = ' + x[0]+ '; new possible states = ' + str(sorted(x[1])) + '\n ' 
    s += ' Input = ' + result[-1][0] + '; new possible states = ' + str(sorted(result[-1][1])) + '\n' 
    s += 'Stop state(s) = ' + str(sorted(result[-1][1])) 
    return s 
관련 문제