You are on page 1of 1

STRINGS

Strings are immutable.


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)

You might also like