Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: must be str, not tuple [duplicate]

Tags:

python

"TypeError: must be str, not tuple" for the following code:

receipt.write(output_to_receipt)

Please may someone explain what this error is?

like image 841
rn01 Avatar asked Apr 27 '16 11:04

rn01


2 Answers

Change receipt.write(output_to_receipt) to receipt.write(str(output_to_receipt)).

This will change output_to_receipt which is a tuple to a string and you'll be able to write.

like image 86
Avión Avatar answered Oct 15 '22 12:10

Avión


output_to_receipt is a tuple, so you need to convert it to a string with str(output_to_receipt) or "".join(output_to_receipt) for example.

like image 39
Sven Hakvoort Avatar answered Oct 15 '22 11:10

Sven Hakvoort