Hey, in this challenge they would pass you a single string such as "functions" - as it's not multiple arguments (a list), there is no need to unpack the string variable. It would result in an error anyways as you cannot call .lower() or any of the other functions on a tuple or list. - Regarding the last return statement, it would also raise an Error as .reverse() does not exist, there are many ways to reverse a string but by far the easiest one, in my opinion, is to just use string[::-1] - it returns all characters of the string backwards - The last thing would be returning a tuple of the answers - just put them in a single return statement and separate them with commas (you could add brackets if it makes it easier to understand) python def stringcases(string): return ( string.upper(), string.lower(), string.title(), string[::-1] ) Answer from diogorferreira on teamtreehouse.com
🌐
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.
Discussions

Python error : 'tuple' object has no attribute 'upper' - Stack Overflow
3 'AttributeError: 'tuple' object has no attribute 'lower'' - Why doesn't the '.lower()' method doesn't work here in Python? More on stackoverflow.com
🌐 stackoverflow.com
May 24, 2017
Python openpyxl module says: AttributeError: 'tuple' object has no attribute 'upper' - Stack Overflow
Installed Python 3.4 and modules jdcal and openpyxl: Trying myself on the openpyxl library to read and write XLSX files from Python. I installed the jdcall module and the openpyxl module. Code let... More on stackoverflow.com
🌐 stackoverflow.com
AttributeError: 'tuple' object has no attribute 'upper'
AttributeError: 'tuple' object has no attribute 'upper' (2 additional frame(s) were not displayed) ... More on github.com
🌐 github.com
1
January 17, 2018
python - AttributeError: 'tuple' object has no attribute - Stack Overflow
I'm a beginner in python. I'm not able to understand what the problem is? def list_benefits(): s1 = "More organized code" s2 = "More readable code" s3 = "Easier code reuse... More on stackoverflow.com
🌐 stackoverflow.com
Top answer
1 of 3
1

If you print the value of words[i] after your attempted character replacements you will see that it is set to a tuple, e.g.

('word', (',', ''), ('/', ''), ('?', ''), ('!', ''))

So the line that tries to remove unwanted punctuation actually creates a tuple because that's what the comma separated items are, i.e.

words[i].replace(".", ""), (",", ""), ("/", ""), ("?", ""), ("!", "")

is actually a tuple consisting of words[i].replace(".", "") followed by (",", ""), etc.

You might have meant to chain a whole lot of replace operations together, but that would need to look like this:

words[i].replace(".", "").replace(",", "").replace("/", "").replace("?", "").replace("!", "")

But that is pretty ugly, and it's restricted to just a few punctuation symbols. str.translate() is better:

words[i] = words[i].translate(None, '.,/?!')

or, if you want to get rid of all punctuation you can use string.punctuation:

import string
words[i] = words[i].translate(None, string.punctuation)

Or, if you are using Python 3:

import string
words[i] = words[i].({ord(c):None for c in string.punctuation})

There are other problems in your code, but see if you can correct this first issue first.

2 of 3
0

in this line:

words[i] = words[i].replace(".", ""), (",", ""), ("/", ""), ("?", ""), ("!", "")

you assign tuple into words[i]. i guess you want to replace several character and that you mean to do this:

words[i] = words[i].replace(".", "").replace(",", "").replace("/", "").replace("?", "").replace("!", "")

several values with comma between them are tuple. 1,5,6 is the same as (1,5,6) so
words[i].replace(".", ""), (",", ""), ("/", ""), ("?", ""), ("!", "")
is the same as
(words[i].replace(".", ""), (",", ""), ("/", ""), ("?", ""), ("!", ""))

in addition, you can't assign into tuple, therefore. the line

wordCount[words[i]] = 1 

can throw an exception, you need to change wordCountint to a dict (when you create it):

wordCount = {}
🌐
GitHub
github.com › inspirehep › inspire-next › issues › 3123
AttributeError: 'tuple' object has no attribute 'upper' · Issue #3123 · inspirehep/inspire-next
January 17, 2018 - AttributeError: 'tuple' object has no attribute 'upper' (2 additional frame(s) were not displayed) ...
Author   david-caro
🌐
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 list class takes an iterable and returns a list object. If you created the tuple by mistake, you have to correct the assignment. ... If you meant to access an element at a specific index in a tuple, use square brackets. ... Copied!my_tuple = ('bobby', 'hadz', 'com') print(my_tuple[0].upper()) # 👉️ "BOBBY" print(my_tuple[1].upper()) # 👉️ "HADZ"
Find elsewhere
🌐
Free Python Source Code
freepythonsourcecode.com › post › 117
With Examples Fix attributeerror: 'tuple' object has no attribute ...
September 29, 2024 - The AttributeError: 'tuple' object has no attribute, which occurs when accessing an attribute or method that doesn't exist for a tuple object in Python.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-attributeerror-object-has-no-attribute
How to fix AttributeError: object has no attribute - GeeksforGeeks
July 23, 2025 - It typically consists of two parts: "AttributeError" and "Object has no attribute." The former indicates the type of error, and the latter suggests that the attribute we are trying to access does not exist for the object.
🌐
Python Forum
python-forum.io › thread-24643.html
'tuple' object has no attribute 'data'
I am trying to determine time complexity of the MergeSort algorithm below: def sortedMerge(self, a, b): result = None if a == None: return b if b == None: return a if a.data
🌐
Python Pool
pythonpool.com › home › blog › demystifying python attribute error with examples
Demystifying Python Attribute Error With Examples - Python Pool
June 14, 2021 - But if try using this upper() on a string, we would have got a result because a string can be qualified as upper or lower. Sometimes when we want to concatenate two strings we try appending one string into another, which is not possible and we get an Attribute Error. string1="Ashwini" string2="Mandani" string1.append(string2) Output- AttributeError: 'str' object has no attribute 'append' Same goes with tuples, a=tuple((5,6)) a.append(7) Output- AttributeError: 'tuple' object has no attribute 'append' Sometimes, what we do is that we try to access attributes of a class which it does not possess.
🌐
GitHub
github.com › AntonOsika › gpt-engineer › issues › 150
AttributeError: 'tuple' object has no attribute 'expandtabs' · Issue #150 · AntonOsika/gpt-engineer
June 18, 2023 - File "/opt/miniconda3/envs/gpt-eng/lib/python3.11/inspect.py", line 873, in cleandoc lines = doc.expandtabs().split('\n') ^^^^^^^^^^^^^^ AttributeError: 'tuple' object has no attribute 'expandtabs'
Author   gchlebus
🌐
GitHub
github.com › XanaduAI › QMLT › issues › 7
AttributeError: 'tuple' object has no attribute 'type' · Issue #7 · XanaduAI/QMLT
January 28, 2019 - I am finding the error after installing QMLT in my ubuntu 18.04. import strawberryfields as sf Traceback (most recent call last): File " ", line 1, in File "/usr/local/lib/python3.6/...
Author   Ayushprasad28
🌐
Python.org
discuss.python.org › python help
AttributeError: 'tuple' object has no attribute 'enter' - Python Help - Discussions on Python.org
March 5, 2025 - Help! I’m coding a game program for my daughter and I come up with the following error: Traceback (most recent call last): File “/home/roberto-padilla/mystuff/ella_game.py”, line 193, in a_game.play() File “/home/roberto-padilla/mystuff/ella_game.py”, line 22, in play next_scene_name = current_scene.enter() ^^^^^^^^^^^^^^^^^^^ AttributeError: ‘tuple’ object has no attribute ‘enter’ Here’s the code: class Engine(object): def __init__(self, scene_map): self.scene_map = scen...
🌐
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?