with the original string centered to a total of width columns and filled with fillchar in columns that do not have characters >>> str1="Welcome" >>> print(str1.center( ,'*') ) ****Welcome**** find(sub[, start[, end]]) The function is used to search the first occurrence of the sub string in the given string. It returns the index at which the substring starts. It returns - if the substring does not occur in the string. >>>str1=’mammals’ >>>str1.find(‘ma’) On omitting the start parameters, the function starts the search from the beginning.
>>>str1.find(‘ma’, ) >>>str1.find(‘ma’, , ) - Displays - because the substring could not be found between the index and - . >>>str1.find(‘ma’, , ) 12th Computer Chapter - - Syntax Description Example isalnum( ) Returns True if the string contains only letters and digit. It returns False. If the string contains any special character like _, @, #, *, etc.
>>>str1=’Save Earth’ >>>str1.isalnum() False The function returns False as space is an alphanumeric character. >>>’Save1Earth’.isalnum() True isalpha( ) Returns True if the string contains only letters. Otherwise return False. >>>’Click123’.isalpha() False >>>’python’.isalpha( ) True isdigit( ) Returns True if the string contains only numbers.
Otherwise it returns False. >>> str1=’Save Earth’ >>>print(str1.isdigit( )) False lower( ) Returns the exact copy of the string with all the letters in lowercase. >>>str1=’SAVE EARTH’ >>>print(str1.lower()) save earth islower( ) Returns True if the string is in lowercase. >>> str1=’welcome’ >>>print (str1.islower( )) True isupper( ) Returns True if the string is in uppercase.
>>> str1=’welcome’ >>>print (str1.isupper( )) False upper( ) Returns the exact copy of the string with all letters in uppercase. >>> str1=’welcome’ >>>print (str.upper( )) WELCOME title( ) Returns a string in title case >>> str1='education department' >>> print(str1.title()) Education Department swapcase( ) It will change case of every character to its opposite case vice-versa. >>> str1="tAmiL NaDu" >>> print(str1.swapcase()) TaMIl nAdU 12th Computer Chapter - - Strings and String Manipulation Syntax Description Example count(str, beg, end) Returns the number of substrings occurs within the given range. Remember that substring may be a single character.
Range (beg and end) arguments