[Python] "TypeError: '>' not supported between instances of 'str' and 'int'" 해결


[Python]

문제상황: 파이썬에서 리스트를 정렬하려고 할 때, 문자열과 정수가 혼합된 경우 에러가 발생할 수 있습니다. 예를 들어, 사용자의 이름과 나이를 포함하는 리스트를 나이 순으로 정렬하려고 하는 다음과 같은 코드를 작성했습니다. user_list = [ {"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}, {"name": "Charlie", "age": 35} ] sorted_list = sorted(user_list, key=lambda x: x['age'], reverse=True)이 코드를 실행하면 다음과 같은 에러로그가 발생합니다. TypeError: '>' not supported between instances of &#..


원문링크 : [Python] "TypeError: '>' not supported between instances of 'str' and 'int'" 해결