👉 기본 환경
- Language: Python
- IDE: Replit
⌨️ 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# 🚨 Don't change the code below 👇
student_scores = input("Input a list of student scores ").split()
for n in range(0, len(student_scores)):
student_scores[n] = int(student_scores[n])
print(student_scores)
# 🚨 Don't change the code above 👆
#Write your code below this row 👇
max = 0;
for score in student_scores:
if max < score:
max = score;
print(f"The highest score in the class is: {max}");
print(max(student_scores));
|
🖨️오류
TypeError: 'int' object is not callable
📡 원인
max()를 사용하기 전에 max 변수를 정의하여 max()를 사용할 수 없게 됨
📰 해결 방법
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# 🚨 Don't change the code below 👇
student_scores = input("Input a list of student scores ").split()
for n in range(0, len(student_scores)):
student_scores[n] = int(student_scores[n])
print(student_scores)
# 🚨 Don't change the code above 👆
#Write your code below this row 👇
max_score = 0;
for score in student_scores:
if max_score < score:
max_score = score;
print(f"The highest score in the class is: {max}");
print(max(student_scores));
|
max 변수 이름을 max_score로 변경하여 max()와 중복되지 않게 함
⭐ 내장 함수와 변수명이 중첩되지 않도록 유의
'Python > Python with Error' 카테고리의 다른 글
[해결 방법] TypeError: list indices must be integers or slices, not str (0) | 2023.08.14 |
---|---|
[해결 방법] TypeError: list.count() takes exactly one argument (0) | 2023.08.13 |
[해결 방법] ValueError: list.remove(x): x not in list (0) | 2023.08.13 |
[해결 방법] TypeError: 'int' object is not iterable (0) | 2023.08.13 |
[해결 방법] IndexError: list index out of range (0) | 2023.08.13 |