편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2019.12.11

    파이썬 이중반복문 빠져나가고 싶습니다.. 날개를 주세요..


    new_score = []
    
    N = int(input())
    
    breaker = False
    
    while True: #잘못입력하면 다시 입력
    
        score = list(map(int, input().split())) 
    
        if len(score) == N:
            for s in score:
                if s <= 0 or s > 100:
                    print("점수오류: 재입력")
                    continue
                elif 100 >= s > 0:
                    breaker = True
                    break
    
        elif breaker == True:
            break
    
        else:
            print("점수초과: 재입력")
            continue
    
    for i in score:
    
        new_score.append(i/max(score) * 100)
    
    print(new_score)
    

    점수가 잘못입력 되었거나 (100초과 0이하) 틀린개수만큼 입력됬을시 다시 입력하는 이중 반복문인데요. 제대로 입력되었을시(100이하 0초과) while문 밖으로 빠져나가질 않네요. 도와주세요. 추가로 해당 코드를 좀더 간결히 표현할수 있는 방법이 있으면 알려주세요.

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

    파이썬 이중반복문 빠져나가고 싶습니다.. 날개를 주세요..


    new_score = []

    N = int(input())

    breaker = False

    while True: #잘못입력하면 다시 입력

    score = list(map(int, input().split())) 
    
    if len(score) == N:
        for s in score:
            if s <= 0 or s > 100:
                print("점수오류: 재입력")
                continue
            elif 100 >= s > 0:
                breaker = True
                break
    
    elif breaker == True:
        break
    
    else:
        print("점수초과: 재입력")
        continue
    

    for i in score:

    new_score.append(i/max(score) * 100)
    

    print(new_score)

    점수가 잘못입력 되었거나 (100초과 0이하) 틀린개수만큼 입력됬을시 다시 입력하는 이중 반복문인데요. 제대로 입력되었을시(100이하 0초과) while문 밖으로 빠져나가질 않네요. 도와주세요 추가로 해당 코드를 좀더 간결히 표현할수 있는 방법이 있으면 알려주세요.