new_score = []
N = int(input())
breaker = False
whileTrue: #Enter again if incorrectly
score = list(map(int, input().split()))
if len(score) == N:
for s in score:
if s <= 0 or s > 100:
print("Score Error: Re-entering")
continue
elif 100 >= s > 0:
breaker = True
break
elif breaker == True:
break
else:
print ("Score Exceeded: Re-entered
continue
for i in score:
new_score.append(i/max(score) * 100)
print(new_score)
This is a double repeat statement that is re-entered when the score is incorrectly entered (greater than 100 and less than 0). If it's entered correctly (less than 100), it doesn't go out of the while statement. Help me. Please let me know if there is any other way to express the code more concisely.
python
new_score = []
N = int(input())
whileTrue: #Enter again if incorrectly
breaker = True
score = list(map(int, input().split()))
if len(score) == N:
for s in score:
if s <= 0 or s > 100:
print("Score Error: Re-entering")
breaker = False
break;
if breaker == True:
break
else:
print ("Score Exceeded: Re-entered
continue
for i in score:
new_score.append(i/max(score) * 100)
print(new_score)
I don't quite understand the meaning of the problem, but this should be accurate.
© 2024 OneMinuteCode. All rights reserved.