String Operations in Python
|
|
| String Operations in Python |
As with integers and floats, strings in Python can be added, using a process called concatenation, which can be done on any two strings.
print('Spam' + "eggs" + 'bacon' + 'sausage' + "spam")
Even if your strings contain numbers, they are still added as strings rather than integers.
print("2" + "2" + "4")
Adding a string to a number produces an error, as even though they might look similar, they are two different entities.
RUN