Hi all , I will show how to use some string related function and operations on list datastructure in python
String function
Length of string
len(string) - > This will bring the length of the string passed to it.
Check if a character in string is upper case of lower case
string[i].isupper() - > This is for checking upper case
sttring[i].islower() - > this is for checking lower case
Convert a character to upper case or lower case
a = string[i].upper() - > This is for converting a character to upper case
a = string[i].lower() - > This is for converting a character to lower case
Please note here i means the index of the character in the string.
Split a line of words
k = string.split(" ")
Here the string is split and words a assigned to a list. The delimited used is " "
List operations
Initialize as list
K = []
This will initialize a list
Add or append a value to list
k.append("a") - > This will add character a to list K.
Comments
Post a Comment