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:

For upper letters use upper()

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)

It will return true if it is present and false if not.

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:

The ” ” puts a space between the words.

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:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s