'TypeError: must be str, not tuple [duplicate]
"TypeError: must be str, not tuple" for the following code:
receipt.write(output_to_receipt)
Please may someone explain what this error is?
Solution 1:[1]
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.
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sven Hakvoort |
Solution 2 |