You're missing the open.
openfile = open('test.txt','w')
And at the end there are missing parens when you try to close the file
openfile.close()
Edit: I just saw another problem.
openfile.write(str(cost)+'\n')
Answer from Matthias on Stack OverflowYou 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!"
You're returning a tuple. Index it.
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!"
AttributeError: 'tuple' object has no attribute '' Error Help
AttributeError: 'tuple' object has no attribute 'enter'
python - How to fix "tuple object has no attribute"? - Stack Overflow
opencv - AttributeError: 'tuple' object has no attribute 'write' , instance segmentation python - Stack Overflow
Videos
I am trying to make a discord bot that would turn a message into lowercase. I am encountering an error, as the title suggests, "AttributeError: 'tuple' object has no attribute 'lower'. "
Here is my code if anyone can help.
https://hastebin.com/ibareyilax.py
If this is the wrong subreddit I don't mind taking down my post and posting it elsewhere.
Result is a tuple of length 2 whereas it should be a simple type you can change line 38 to :
result[0].write(frame.astype(np.uint8))
The value python round(cap.get(cv.CAP_PROP_FRAME_HEIGHT)) does not seem to do anything so you can remove by it replacing lines 12-14 by:
result = cv.VideoWriter('sample.avi',
cv.VideoWriter_fourcc(*'MJPG'),
22, size)
In this line your are creating a tupple
result = cv.VideoWriter('sample.avi', cv.VideoWriter_fourcc(*'MJPG'), 22, size), round(cap.get(cv.CAP_PROP_FRAME_HEIGHT))
instead do simply
result = cv.VideoWriter('sample.avi', cv.VideoWriter_fourcc(*'MJPG'), 22, size)
variableX = round(cap.get(cv.CAP_PROP_FRAME_HEIGHT))