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

AttributeError: 'tuple' object has no attribute 'join' - Post.Byes
Why this code return error AttributeError: 'tuple' object has no attribute 'join' Any help will be appreciated; Thanks import string template_text = ''' Delimiter : %% Replaced : %with_underscore Ignored : %notunderscored ''' d = { 'with_underscore' : 'replaced', 'notunderscored' : 'not replaced' More on post.bytes.com
🌐 post.bytes.com
November 7, 2012
python - AttributeError: 'tuple' object has no attribute 'append' - Stack Overflow
This did not give error for w because I had initialized w to w = [] without comma(,) and it treated as list but when I applied the same for x it gave the error because I have initialized it as x = [], with comma here and it treated as tuple. for i in range(4): y.append(i) # throws error AttributeError: 'tuple' object has ... More on stackoverflow.com
🌐 stackoverflow.com
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
ERROR: AttributeError: 'tuple' object has no attribute 'to'
* batch_idx / len(train_loader), ... data, target = data.to(device), target.to(device) 11 optimizer.zero_grad() 12 output = model(data) AttributeError: 'tuple' object has no attribute 'to'... More on github.com
🌐 github.com
3
January 1, 2024
🌐
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.
🌐
LearnDataSci
learndatasci.com › solutions › python-attributeerror-tuple-object-has-no-attribute
Python AttributeError: 'tuple' object has no attribute – LearnDataSci
It's important to remember that any functions returning multiple values will automatically store the outputs in a tuple, which could also potentially cause this error to come up. Luckily, the error is pretty easy to avoid in most cases by unpacking the tuple first, assigning the values to variables. Alternatively, using indices to index a tuple is also a viable solution. ... Join over 7,500 data science learners.
🌐
Bytes
bytes.com › home › forum › topic › python
AttributeError: 'tuple' object has no attribute 'join' - Post.Byes
November 2, 2015 - Why this code return error AttributeError: 'tuple' object has no attribute 'join' Any help will be appreciated; Thanks import string template_text = ''' Delimiter : %% Replaced : %with_underscore Ignored : %notunderscored ''' d = { 'with_underscore' : 'replaced', 'notunderscored' : 'not replaced'
🌐
Researchdatapod
researchdatapod.com › home › how to solve python attributeerror: ‘tuple’ object has no attribute ‘append’
How to Solve Python AttributeError: 'tuple' object has no attribute 'append' - The Research Scientist Pod
March 11, 2022 - You can also convert the tuple you want to change to a list, call the append method, then convert the list back to a tuple. For further reading on AttributeErrors, go to the articles: How to Solve Python AttributeError: ‘list’ object has no attribute ‘join’.
🌐
GitHub
github.com › angr › angr › issues › 2479
AttributeError: 'tuple' object has no attribute 'merge' · Issue #2479 · angr/angr
January 18, 2021 - You must be signed in to change notification settings · Fork 1.1k · Star 7.8k · New issueCopy link · New issueCopy link · Closed · Closed · AttributeError: 'tuple' object has no attribute 'merge'#2479 · Copy link · BitTheByte · opened · on Jan 18, 2021 ·
Find elsewhere
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!
July 14, 2018 - 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.
🌐
CopyProgramming
copyprogramming.com › howto › list-object-has-no-attribute-join
Python: 'join' attribute is missing in the 'list object'
August 6, 2023 - Python multiprocessing error when passing a list, I'm not 100% sure how Process works in this context, but what you have written here: for process in enumerate(processes): process.join(). ... I am attempting to enhance the speed of CSV file reading by utilizing the multiprocessing library. I have successfully accomplished this using the Pool function and now I am attempting to achieve the same result using the Process() function. However, upon running the code, an error is being encountered which states the following: An AttributeError was raised indicating that ' tuple' object ' does not possess the 'join' attribute.
🌐
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...
🌐
GitHub
github.com › pytorch › pytorch › issues › 116584
ERROR: AttributeError: 'tuple' object has no attribute 'to' · Issue #116584 · pytorch/pytorch
January 1, 2024 - * batch_idx / len(train_loader), ... data, target = data.to(device), target.to(device) 11 optimizer.zero_grad() 12 output = model(data) AttributeError: 'tuple' object has no attribute 'to'...
Author   andysingal
🌐
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?

🌐
GitHub
github.com › borgbackup › borg › issues › 7073
2.0.0b3: 'tuple' object has no attribute 'segment' · Issue #7073 · borgbackup/borg
October 3, 2022 - $ tar -C /etc -c fstab | borg -r test import-tar test-4 - Local Exception Traceback (most recent call last): File "borg/archiver/__init__.py", line 594, in main File "borg/archiver/__init__.py", line 522, in run File "borg/archiver/_common.py", line 155, in wrapper File "borg/archiver/tar_cmds.py", line 253, in do_import_tar File "borg/archiver/tar_cmds.py", line 327, in _import_tar File "borg/archive.py", line 681, in save File "borg/manifest.py", line 287, in write File "borg/repository.py", line 1311, in put AttributeError: 'tuple' object has no attribute 'segment' Platform: Linux tmp-borg
Author   pgerber
🌐
GitHub
github.com › certbot › certbot › issues › 4662
AttributeError: 'tuple' object has no attribute 'add' · Issue #4662 · certbot/certbot
May 14, 2017 - My operating system is (include version): CentOS7.3 certbot-0.14.0 Python2.7.13 or 3.5.3 2017-05-14 15:13:31,096:DEBUG:certbot.main:certbot version: 0.14.0 2017-05-14 15:13:31,097:DEBUG:certbot.main:Arguments: [] 2017-05-14 15:13:31,098:...
Published   May 14, 2017
Author   oneinstack