파이썬/exercise
5-1. python 학생 평균키 구하기(for반복문 연습)
태지쌤
2023. 1. 4. 10:56
반응형
for반복문 연습을 위한 것이므로 sum, len 함수 사용하지 않고 문제해결하기
# 🚨 Don't change the code below 👇
student_heights = input("Input a list of student heights ").split()
for n in range(0, len(student_heights)):
student_heights[n] = int(student_heights[n])
# 🚨 Don't change the code above 👆
#Write your code below this row 👇
i = 0
sum = 0
for height in student_heights:
sum += height
i += 1
avg = round(sum / i)
print(avg)
반응형