One of the many basic data types of a programing language is the string data type, this post will be just a quick overview of strings in python. A string can often be considered a sequence of characters, so they are often used as a way to store text values, however they can also often be used to store an array of values like that of a list.
On top of the very basics of strings, there are also a number of string methods with the data type. So it would be a good idea to go over some of these methods that there are to work with when it comes to strings, such as uppercase, cont, find and so forth.
Well I have to start somewhere when it comes to learning a thing or two about strings in python. In this section I will just be going over a few quick basic examples of strings. There is just creating a string literal value for starters, but then there are other basic things that I should have solid when it comes to learning about strings in a new language such as python. One thing that comes to mind with this is concatenation of strings, there is also the question of how to go about converting a string of a number to an actual number data type, and much more just when it comes to the basics. So lets get this part out of the way so i can move on to the good stuff.
So maybe one of the first things I should learn when it comes to how to work with strings in a new programing environment is to learn how to create just a simple string literal value.
On top of just being a simple string literal, a string can also be the result of an expression. When doing so it is called for to make sure that any value that is not a string is converted to a string. If I add a value that is a string, to a value that is not a string, I can end up with a type error.
One way to do type conversion of a string of a number to an actual number data type would be to use the int built in function.
There are other built in functions such as the float function, but the basic idea is more or less the same. In any case to convert a string value to another value it will just require passing the string value to the appropriate built in function, or whatever method or function there is to preform the type conversion.
A string can be looped over with a for loop in python.
The split string method can be used to create a list iof strings from a string with a separator. There is however one major drawback with this method though which is that I can not give an empty string as a separator. So then the split method will fall short if I want to split a sing into a list of chars. However one work around would be to pass the string value to the list built in function.
There is a count method that will return the number of times that a sub string happens in the given string that the method is called off of.
Well that is it for now when it comes to strings in python. I am still fairly new with python myself as of this writing so at some point in the future I will have to come back and edit this post as I start to pick pick up more when it comes to strings and python in general actually.