Just trying to make a tuple to add to make my main programming. Anyway this is my code-
print"I have a few things to finish my exam, but i might need more"
exam=("Brain","Computer","python")
print "The stuff i have are:"
for stuff in exam:
print stuff
print"I still need my previous assignments!"
extra=("Assignments")
exam += extra
for stuff in exam:
print stuff
I keep getting the can only concatenate tuple error. Anyone have a clue my issue/how to fix it? Greatly appreciated.
Well that is because according to the python doc
Tuples are constructed by the comma operator (not within square brackets), with or without enclosing parentheses, but an empty tuple must have the enclosing parentheses, such as a, b, c or (). A single item tuple must have a trailing comma, such as (d,).
so if you do this to your code it has to work
extra = "Assignments",
or
extra = ("Assignments",)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With