String methods in python with examples – My Programming School


String methods in python with examples – My Programming School

String methods in python with examples

String modules include many useful constants and classes, as well as some deprecated inheritance functions that are also available as string methods. In addition, Python’s built-in string classes support sequence type methods described in sequence types – str, bytes, bytearray, list, tuple, category section, and string-specific methods also described in the string-specific methods section. To output formatted strings, see the String Formatting section. Also, see the re-module for string functions based on regular expressions.

Aim

To perform  various operation on string using string libraries with algorithm

Implement python  various operation on string using string libraries | algorithm

step 1: Start step 2: initialise upper case letters capotal = str.upper() step 3: Initialise upper case letter small = capital.lower() step 4: Replace str1 to str2 str2 = str1.replace(“students’,”engineer”) step 5: print left and right strips left  = str1.strip() right = str1.strip() step 6: print prefixes prefix1 = str1.startwith(“wel come”) step 7: end

Source Code to implement string methods in python

str1 = “welcome to all student” capital = str1.upper() print(capital) str2 = “WELCOME TO MITS”lower = str2.lower() print(str2) str3 = str2.replace(“MITS”,”madanapalle”) print(str3) str4 = “This is an example of strip”left = str4.strip() print(left) prefix1 = str1.startswith(‘hellow’) print(prefix1) prefix2 = str1.startswith(‘wel’) print(prefix2) prefix3 = str1.endswith(‘student’) print(prefix3) Output:
String methods in python with examples
Related Link: String methods in python with examples Tags python string format,python string split,python string,python string replace, python string methods,python string find,python string index,python string operations,

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories

You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.