편집 기록

편집 기록
  • 프로필 엽토군님의 편집
    날짜2019.02.23

    checkiO하다가 첫번째부터 막히네요


    조건문 내에 if을 지정해줬는데

    local variable 'aa' referenced before assignment

    라고 뜨면서 error 가 나옵니다.

    혹시 참일때만 aa="T"라고 지정해주고 거짓일때는 지정을 안해줘서 오류가 나는건가요?

    조건문 여러개 쓰고 마지막에

    if aa=="T":

    이런 조건문을 붙이기는 했거든요?

    ---------------------------------------------------------------2019/2/22 수정----------------------------------------------------------------------

    def second_index(text: str, symbol: str) -> [int, None]:
    
       """
            returns the second index of a symbol in a given text
        """
    
        if symbol in text:
            x = text.find(symbol)
            if x == 0:
                text = text[1:]
            else:
                text = text[0:x]+text[x+1:]
    
            if symbol in text:
                y = text.find(symbol)+1
            else : y = none 
    
        return y
    

    요래 했는데 UnboundLocalError: local variable 'y' referenced before assignment, second_index, 16 라는 오류가 뜨네요

  • 프로필 알 수 없는 사용자님의 편집
    날짜2019.02.22

    checkiO하다가 첫번째부터 막히네요


    조건문 내에 if을 지정해줬는데

    local variable 'aa' referenced before assignment

    라고 뜨면서 error 가 나옵니다.

    혹시 참일때만 aa="T" 라고 지정해주고 거짓일때는 지정을 안해줘서 오류가 나는건가요?

    조건문 여러개 쓰고 마지막에

    if aa=="T":

    이런 조건문을 붙이기는 했거든요?

    ---------------------------------------------------------------2019/2/22 수정----------------------------------------------------------------------

    def second_index(text: str, symbol: str) -> [int, None]:

    """ returns the second index of a symbol in a given text """

    if symbol in text:
        x = text.find(symbol)
        if x == 0:
            text = text[1:]
        else:
            text = text[0:x]+text[x+1:]
    
        if symbol in text:
            y = text.find(symbol)+1
        else : y = none 
    
    return y
    

    요래 했는데 UnboundLocalError: local variable 'y' referenced before assignment, second_index, 16 라는 오류가 뜨네요