Anyone Can Code.
Concatenation simply means to join. Python supports joining strings together with the
+ (pretty cool right?).
Keep in mind that since whitespace is counted as a character, concatenation will not result in the creation of whitespaces between words, unless specified beforehand.
Let's look at the next two code blocks to see how.
As you can see in the second block, we left a space after
"Hello". This space
is counted as a character and hence we get the output
Python allows users to repeat srings using the
* operator. They must always be
multiplied by a positive integer.
Python has two membership operators
not in. As the names
suggest, these are used to check whether a character or set of characters
is in a particular string or not. The final result will be a Boolean - either
Slicing is used to extract certain sections of a string, through specifying an index range and step value.
You know what indices are, but what is a step value? Simply put, a step value is the
difference between the integer values of indices. For example,
if the index range is
0:8 and the step value is
2, the program
will access every second character of the string i.e.
Programm Pgm nmag
That's it for this tutorial! Scroll up and click on Next for the next tutorial!