You return four variables s1,s2,s3,s4 and receive them using a single variable obj. This is what is called a tuple, obj is associated with 4 values, the values of s1,s2,s3,s4. So, use index as you use in a list to get the value you want, in order.

Copyobj=list_benefits()
print obj[0] + " is a benefit of functions!"
print obj[1] + " is a benefit of functions!"
print obj[2] + " is a benefit of functions!"
print obj[3] + " is a benefit of functions!"
Answer from Aswin Murugesh on Stack Overflow
Discussions

python - Trying to fill cells color in excel using openpyxl but receiving an error saying "AttributeError: 'tuple' object has no attribute 'fill'" - Stack Overflow
The functionality has been working (*gives pat on back before asking for help), but right now I am trying to format the document to mimic their current one. In this for loop, I am trying create a color-filled cell for the labels of the datas under each column. However, I keep receiving "AttributeError: 'tuple' object ... More on stackoverflow.com
🌐 stackoverflow.com
September 8, 2023
'tuple' object has no attribute 'value'
Please post the entire error message with all the information. More on reddit.com
🌐 r/learnpython
7
0
May 18, 2020
AttributeError: 'tuple' object has no attribute 'enter'
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/r… More on discuss.python.org
🌐 discuss.python.org
2
0
March 5, 2025
I'm getting an error that is 'tuple' object has no attribute 'append'. How do I fix?
Scott Cannon is having issues with: I keep getting this error when trying to finish the random_game challenge: Traceback (most recent call last): File "random_game.py", line 21 ... More on teamtreehouse.com
🌐 teamtreehouse.com
3
April 22, 2015
🌐
LearnDataSci
learndatasci.com › solutions › python-attributeerror-tuple-object-has-no-attribute
Python AttributeError: 'tuple' object has no attribute – LearnDataSci
The underscore conveys to readers of your code that you intend not to use the index value. The error AttributeError: 'tuple' object has no attribute is caused when treating the values within a tuple as named attributes.
🌐
Stack Overflow
stackoverflow.com › questions › 76868265 › trying-to-fill-cells-color-in-excel-using-openpyxl-but-receiving-an-error-saying
python - Trying to fill cells color in excel using openpyxl but receiving an error saying "AttributeError: 'tuple' object has no attribute 'fill'" - Stack Overflow
September 8, 2023 - If you were thinking to fill all cells in that range in the one command, it cannot be done. fill is an attribute for an individual cell reference. You would need to extract the individual cell object from the tuple.
🌐
Reddit
reddit.com › r/learnpython › 'tuple' object has no attribute 'value'
r/learnpython on Reddit: 'tuple' object has no attribute 'value'
May 18, 2020 -

hii folks,

i am trying to write data to a excel file.when using for loop,to assign the values to cells,it's giving me the error that 'tuple' object has no attribute 'value' at line 6.

import openpyxl
wb=openpyxl.Workbook()
ws=wb.active
for i in range(10):
	index="A"+str(i)
	ws[index]=i

please help me this error.

🌐
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.
🌐
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...
Find elsewhere
🌐
Autodesk
download.autodesk.com › global › docs › softimage2014 › en_us › sdkguide › files › script_trouble_ERRORtupleqobjecthasnoattribute.htm
ERROR : 'tuple' object has no attribute
Use the tuple-style syntax as explained in Getting Output Arguments from Methods. ... Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
🌐
GitHub
github.com › KMKfw › kmk_firmware › issues › 597
RGB Backlighting crashes the board when toggled · Issue #597 · KMKfw/kmk_firmware
September 21, 2022 - Traceback (most recent call last): ... "kmk/extensions/RGB.py", line 273, in set_hsv_fill File "kmk/extensions/RGB.py", line 297, in set_rgb_fill AttributeError: 'tuple' object has no attribute 'fill'...
Author   anventia
Top answer
1 of 4
9

In the line:

Jobs = ()

you create a tuple. A tuple is immutable and has no methods to add, remove or alter elements. You probably wanted to create a list (lists have an .append-method). To create a list use the square brackets instead of round ones:

Jobs = []

or use the list-"constructor":

Jobs = list()

However some suggestions for your code:

opening a file requires that you close it again. Otherwise Python will keep the file handle as long as it is running. To make it easier there is a context manager for this:

with open('Jobs.txt') as openFile:
    x = 1
    while x != 0:
        Stuff = openFile.readline(x)
        if Stuff != '':
            Jobs.append(Stuff)
        else:
            x = 0

As soon as the context manager finishes the file will be closed automatically, even if an exception occurs.


It's used very rarely but iter accepts two arguments. If you give it two arguments, then it will call the first each iteration and stop as soon as the second argument is encountered. That seems like a perfect fit here:

with open('Jobs.txt') as openFile:
    for Stuff in iter(openFile.readline, ''):
        Jobs.append(Stuff)

I'm not sure if that's actually working like expected because openFile.readline keeps trailing newline characters (\n) so if you want to stop at the first empty line you need for Stuff in iter(openFile.readline, '\n'). (Could also be a windows thingy on my computer, ignore this if you don't have problems!)


This can also be done in two lines, without creating the Jobs before you start the loop:

with open('Jobs.txt') as openFile:
    # you could also use "tuple" instead of "list" here.
    Jobs = list(iter(openFile.readline, ''))  

Besides iter with two arguments you could also use itertools.takewhile:

import itertools
with open('Jobs.txt') as openFile:
    Jobs = list(itertools.takewhile(lambda x: x != '', openFile))

The lambda is a bit slow, if you need it faster you could also use ''.__ne__ or bool (the latter one works because an empty string is considered False):

import itertools
with open('Jobs.txt') as openFile:
    Jobs = list(itertools.takewhile(''.__ne__, openFile))
2 of 4
0

The Jobs object you created is a tuple, which is immutable. Therefore, you cannot "append" anything to it.

Try

Jobs = []

instead, in which you create a list object.

🌐
Sololearn
sololearn.com › en › Discuss › 1405271 › attributeerror-tuple-object-has-no-attribute-append
AttributeError: 'tuple' object has no attribute 'append' | Sololearn: Learn to code for FREE!
You have commas at the end of lines 1-4. 1: print("to stop adding numbers type 'quit' "), 2: input_user = input("type here your number:"), 3: result = 0, 4: input_numbers = [], I think Python automatically creates a tuple for lines 2 & 4 because without the parenthesis this is normally a multi-assignment syntax: a,b = b,a ...but without two variables on the left, Python took the 'safe' route, a tuple.
🌐
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?

🌐
Python Forum
python-forum.io › thread-33245.html
AttributeError: 'tuple' object has no attribute 'format'
Confuse where is the error because execute some parts of codes half code run and half give me an error AttributeError: 'tuple' object has no attribute 'format' def __str__(self): return ('{} : {}','[]').format(self._word, self._coords)Erro...
🌐
Reddit
reddit.com › r/askprogramming › 'tuple' object has no attribute 'x'
r/AskProgramming on Reddit: 'tuple' object has no attribute 'x'
March 22, 2021 -

working on an assignment and I've been getting this error a lot with the codes our professor is giving us. Here is an example of a code given:

a = np.random.normal(0, 1, 9).reshape(3, 3)

and it returns:

AttributeError                            Traceback (most recent call last)
<ipython-input-10-d5ba530a56da> in <module>
----> 1 a = np.random.normal(0, 1, 9).reshape(3, 3)

AttributeError: 'tuple' object has no attribute 'random'

so I'm not sure what I'm doing wrong. Any ideas?

*RESOLVED* thank you u/FunkyDoktor

🌐
GitHub
github.com › tensorflow › tensorflow › issues › 38503
AttributeError: 'tuple' object has no attribute 'shape' error while using Google colab · Issue #38503 · tensorflow/tensorflow
April 13, 2020 - I also converted the datagenerator output to a tuple instead of list · AttributeError Traceback (most recent call last) in () 7 epochs=nb_epoch, 8 steps_per_epoch=nb_train_samples, ----> 9 validation_data=gen_valid) 12 frames /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs) 966 except Exception as e: # pylint:disable=broad-except 967 if hasattr(e, "ag_error_metadata"): --> 968 raise e.ag_error_metadata.to_exception(e) 969 else: 970 raise
Author   mkpisk
🌐
Esri Community
community.esri.com › t5 › arcgis-api-for-python-questions › attributeerror-tuple-object-has-no-attribute › td-p › 1182615
Solved: AttributeError: 'tuple' object has no attribute 'c... - Esri Community
June 14, 2022 - Solved: Hi, We work on a dedicated hosted version, so not the cloud solution. When we launch the scripts we manage to load everything to start with. so: import