Strings in Python are immutable sequences of characters that must be enclosed in single quotes or double quotes. Common string methods allow you to check length, convert case, replace substrings, split into a list, and reverse order. Strings can also be used to check if a character or substring exists within another string.
Strings in Python are immutable sequences of characters that must be enclosed in single quotes or double quotes. Common string methods allow you to check length, convert case, replace substrings, split into a list, and reverse order. Strings can also be used to check if a character or substring exists within another string.
Strings in Python are immutable sequences of characters that must be enclosed in single quotes or double quotes. Common string methods allow you to check length, convert case, replace substrings, split into a list, and reverse order. Strings can also be used to check if a character or substring exists within another string.
Immutable: Cannot be change in their place can only be changed by making a copy. It is written in double quotes. A string cannot have" in ".
len(a): to count length of the string.
a.upper(): to make all the letters in string of uppercase a.lower(): to make all the letters in string of lowercase r.strip: characters are used to strip trailing characters like !!!! it cannot remove the starting characters a.replace(): it replaces a word to replaceable words and replaces all occurences a.split(): it cnverts string into list
to reverse a string st1=input("enter a string") print("The", st1,"in reverse order is:") length=len(st1) for i in range(-1,(-length-1),-1): print(st1[i])
to chek whether there is a 0 in
st1=int(input("enter a no.:")) s=str(st1) if "0" in s: print("there is a 0 in", s) else: print("there isn't any 0 in",s)