Skip to main content

Posts

Showing posts with the label String

Python Common String Operations

A string is most popular type in Python. A string can be created by enclosing a sequence of characters in a single or double quotes (' ' or " "). A string module contains a number of powerful methods/function to perform operations on a string. NOTE: string in Python is IMMUTABLE (it cannot be changed of the string) as in many other languages (Java). Length of a string Range slice Accessing a character of a string Converting all string characters to all uppercase letters Converting all string characters to all lowercase letters Capitalizing string String concatenation Fining the index where the sub-string begins/occurs in a string  Check if string contains sub-string String comparison (Equality, less than, greater than, not equal) Breaking a string by ",", "-","  " (space), etc.                              ...