If you see here "Tuples and Sequences" you can see that your data structure is a tuple.

You can see here "More on Lists" that sort() is a function only for arrays.

You can use sorted() to sort arrays or tuples

new_list=("a","g","x","e","s","s")   
a=sorted(new_list) # ['a', 'e', 'g', 's', 's', 'x']
Answer from Hearner on Stack Overflow
🌐
OpenCV
forum.opencv.org › python
AttributeError: 'tuple' object has no attribute 'sort' - Python - OpenCV
March 24, 2022 - Code in Free Course, " opencv-python-free-course-code", produces error as follows: AttributeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_15804/465439247.py in 4 5 # Sort matches by score ----> 6 matches.sort(key=lambda x: x.distance, reverse=False) 7 8 # Remove not so good matches AttributeError: ‘tuple’ object has no attribute ‘sort’ Need help resolving.
Discussions

Sphinx 3.5 causes `AttributeError: 'tuple' object has no attribute 'sort'` on `ctx['css_files']`
Describe the bug Sphinx 3.5 broke the "any iterable" expectation for css_files in HTML context: by calling .sort() on it, the expectation became "list-only", not "any itera... More on github.com
🌐 github.com
3
February 15, 2021
python - AttributeError: 'tuple' object has no attribute 'sort' - Stack Overflow
Here is my code, and i am getting an AttributeError: 'tuple' object has no attribute 'sort. I am trying to do an image alignment and found this standard image alignment code in an article. I am lea... More on stackoverflow.com
🌐 stackoverflow.com
July 28, 2022
Bug Report for combination-target-sum-ii: Solution that should run on initial test cases gives unexpected error
Bug Report for https://neetcode.io/problems/combination-target-sum-ii Please describe the bug below and include any steps to reproduce the bug or screenshots if possible. When inserting the below s... More on github.com
🌐 github.com
0
January 30, 2026
AttributeError: 'tuple' object has no attribute '' Error Help
Remove the * in front of *arg. That is converting the argument into a tuple. More on reddit.com
🌐 r/learnpython
5
9
January 10, 2021
🌐
GitHub
github.com › spmallick › learnopencv › issues › 801
AttributeError: 'tuple' object has no attribute 'sort' · Issue #801 · spmallick/learnopencv
February 20, 2023 - The error message suggests that you are trying to call the sort method on a tuple object, which is not possible because tuples are immutable and do not have a sort method. It seems that in your code, the variable matches is a tuple, and you ...
Author   dacrypt
🌐
GitHub
github.com › sphinx-doc › sphinx › issues › 8889
Sphinx 3.5 causes `AttributeError: 'tuple' object has no attribute 'sort'` on `ctx['css_files']` · Issue #8889 · sphinx-doc/sphinx
February 15, 2021 - Sphinx 3.5 broke the "any iterable" expectation for css_files in HTML context: by calling .sort() on it, the expectation became "list-only", not "any iterable". And now when there's a tuple in css_files, it breaks with an AttributeError:
Author   webknjaz
🌐
Bobby Hadz
bobbyhadz.com › blog › python-attributeerror-tuple-object-has-no-attribute
AttributeError: 'tuple' object has no attribute X in Python | bobbyhadz
April 8, 2024 - The Python "AttributeError: 'tuple' object has no attribute" occurs when we access an attribute that doesn't exist on a tuple.
🌐
GitHub
github.com › neetcode-gh › leetcode › issues › 5383
Bug Report for combination-target-sum-ii: Solution that should run on initial test cases gives unexpected error · Issue #5383 · neetcode-gh/leetcode
January 30, 2026 - class Solution: def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]: res = set() def backtrack(candidate, pos, total): if total == target: res.add(tuple(candidate.copy())) if total >= target: return for i in range(pos, len(candidates)): candidate.append(candidates[i]) backtrack(candidate.copy(), i + 1, total + candidates[i]) candidate.pop() candidates = sorted(candidates) backtrack([], 0, 0) res = list(res) for candidate in res: candidate = list(candidate) return res
Author   ditzaa
Find elsewhere
🌐
LearnDataSci
learndatasci.com › solutions › python-attributeerror-tuple-object-has-no-attribute
Python AttributeError: 'tuple' object has no attribute – LearnDataSci
The error AttributeError: 'tuple' object has no attribute is caused when treating the values within a tuple as named attributes.
🌐
Python Forum
python-forum.io › thread-36492.html
Open CV
Hi all, This post is regarding image registration using open CV. I have come across this article in Geeks for geeks and following is the link: https://www.geeksforgeeks.org/image-regi...cv-python/ I have tried the same code mentioned in the site a...
🌐
Medium
medium.com › swlh › 3-reasons-why-you-should-almost-always-use-sorted-in-python-9fe122e6ce71
3 Reasons Why You Should Almost Always Use sorted() in Python | by Yong Cui | The Startup | Medium
April 24, 2020 - >>> # sort a list using sort() >>> names0 = ['Danny', 'Johnny', 'Billy', 'Donny'] >>> names0.sort() >>> names0 ['Billy', 'Danny', 'Donny', 'Johnny'] >>> >>> # sort a list using sorted() >>> names1 = ['Danny', 'Johnny', 'Billy', 'Donny'] >>> sorted(names1) ['Billy', 'Danny', 'Donny', 'Johnny']
🌐
YouTube
youtube.com › watch
Solving the AttributeError: 'tuple' object has no attribute 'sort' in OpenCV - YouTube
Learn how to resolve the `AttributeError: 'tuple' object has no attribute 'sort'` in OpenCV when working with Python and image processing.---Solving the Attr...
Published   January 13, 2025
Views   7
🌐
Reddit
reddit.com › r/learnpython › getting attributeerror: 'tuple' object has no attribute 'items'
r/learnpython on Reddit: Getting AttributeError: 'tuple' object has no attribute 'items'
February 1, 2021 -
from kubernetes import client, config

config.load_kube_config()

v1 = client.CoreV1Api()
print("Listing services with their IPs:")
ret = v1.list_service_for_all_namespaces_with_http_info(watch=False)
for i in ret.items:
    print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))    

This throws this error: File "filename.py", line 8, in <module> for i in ret.items: AttributeError: 'tuple' object has no attribute 'items'

But when I simply print(ret), it certainly LOOKS like a tuple, which means I should be able to iterate through with tuple.items, no?