Strings...

 test = '''hello, my name is akash kumar.

I am learning python language.
so that i can write some amazing programmes.
'''

# '''print(test)'''
# print(len(test))                     # to check the length of str
# print(test[0])                       # To check the 1st letter of str
# print(test[20:45])                   # To check the letters of str from 20 to 45
# print(test[20:100:6])                # To check the letters of str from 20 to 100 with skip value 6
# # print(test[:45])                   # it will start from 0
# # print(test[100:])                  # it will end on last
# # print(test[-5])                    # reverse search(last alphabet is -1)
# # print(test[-5:-1])                 # check from last to last -5

# print(test.endswith("programmes."))  # to check the str endswith or not
# print(test.endswith(''))             # # to check the str endswith or not

print(test.count("akash"))             # to check how many alphabet or word in str
# print(test.capitalize())             # make 1st word capital
print(test.find("my"))
print(test.replace("i","you"))       # replacing my to your in whole str


No comments:

Post a Comment