파이썬 이중반복문 빠져나가고 싶습니다.. 날개를 주세요..
조회수 4424회
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문 밖으로 빠져나가질 않네요. 도와주세요. 추가로 해당 코드를 좀더 간결히 표현할수 있는 방법이 있으면 알려주세요.
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
1 답변
-
new_score = [] N = int(input()) while True: #잘못입력하면 다시 입력 breaker = True score = list(map(int, input().split())) if len(score) == N: for s in score: if s <= 0 or s > 100: print("점수오류: 재입력") breaker = False break; if breaker == True: break else: print("점수초과: 재입력") continue for i in score: new_score.append(i/max(score) * 100) print(new_score)
문제의 뜻은 잘 이해안돼지만 이것이면 정확할거에요.
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
- 제가 원한대로 바로되네요 정말감사합니다!!! 알 수 없는 사용자 2019.12.12 15:58
- 도움을 주는 사람으로 도와주어 고맙군요... 알 수 없는 사용자 2019.12.12 16:20
댓글 입력