If you come from different programming languages the data type character might be common for you, but in Python this one doesn’t exist. A character in Python is a string with a length of 1.
To be honest I don’t think we have to go trough things like assigning a string to a variable, slicing or how to create multiline strings as these things are self-explaining. If not check out the link at the bottom of this post.
I want to jump directly into some built-in string methods, which I find really helpful.
For example you can use the format()-method to insert numbers into strings like this:
Or imagine a kid is writing on your laptop who her favorite player is. But she strangely mixes upper and lower letters. Use the lower() function:
Or imagine you receive a text and you want to check if a phrase is present in it (and strg+f-function doesn’t work :-P)
To concatenate, or combine, two strings you can use the + operator. This is a pretty cool method, because you can build your sentences like a puzzle and uncomment the words you don’t need:
This list would never and. I just wanted to show you here a taste of the variety of options, which exist to work with strings. Check out this further methods:
For further information about the topic watch this: