Python For Beginner's Day - 6

·

1 min read

String Methods:

  • It has built-in methods which can be used for strings, with this it returns new values but original value will not be changed.

  • capitalize(): converts first character to upper case.

  • casefold(): converts string to lower case.

  • count(): returns number of occurrences a specified value in the string.

  • center(): returns centered string.

  • endswith(): returns true if the string ends with specified value.

  • find(): finds the first occurrence of the specified value.

  • format(): As discussed, it is used for formatting the values and insert them inside the placeholder.

  • index(): finds the first occurrence of the specified value. It is almost same as find() , the only difference is find() returns -1 if value is not present but index throws an exception.

    • - to be continued .......