I have created an empty string:
s = ""
how can I append text to it? I know how to append something to a list like:
list.append(something)
but how one can append something to an empty string?
The right name would be to concatenate a string to another, you can do this with the + operator:
s = ""
s = s + "some string"
print s
>>> "some string"
like this:
s += "blabla"
Please note that since strings are immutable, each time you concatenate, a new string object is returned.
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