In this blog, I am going to give you more information about string sin Python. Strings could be pretty simple things, just some letters after each other wrapped by apostrophes. I already explained the basic information about strings in my blog about the basic types of Python. You can always consult that information back.
In this blog, I am going to focus on how to manipulate string, Because creating is already discussed in the blog that I mentioned above.
A first way to modify a string is to isolate a couple of indexes. The first letter of your string has always the index 0, the second letter 1, and so on. Even spaces, commas and sign in your string gets an index number. It works exactly the same as isolating individual elements out of a list or tuple. So you create your string and gives it a name and then you put in square brackets behind the name the indexes you want to isolate. The string only always keeps his original shape. It is not possible to delete or change elements out of a string in the same way as with a list.
There is also a way to out the whole string in capitals, upper(), in lower case, lower() or removing the spaces at the beginning and ending, strip().
Another modification that you can do with a string is replacing letters with other letters, replace() or split the string in two parts, split(“,”). In the split in my example, I put a comma between the apostrophes, so it will divide the string at the point of the commas. But you can also for example put the c between the apostrophes and then the string would be separated at the c.

The last thing that I want to explain is that you can check if certain characters are present in a string. You can do that with x = “Tec” in txt, that would give the outcome x=true.
You can also easily combine two strings:
string = ‘ Tec, de, Monterrey! ‘
string2=’hallo’
string3= string+string2
print(string3)
outcome: Tec, de, Moterrey! hallo
Hopefully you enjoyed reading this blog again!















