String methods in python with examples – My Programming School easy

String methods in python:

Strings modules include many useful constants and classes, therefore some deprecated inheritance functions that are also available as strings methods. In addition, Python’s built-in string classes support sequence type methods described in sequence types – str, bytes, by the array, list, tuple, category section, and string-specific methods are 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.

Algorithm of String Methods in Python

  • step1: Start
  • step2: initialise upper case letters capital = str.upper()
  • step3: Initialise upper case letter small = capital.lower()
  • step4: 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.start with(“welcome”)
  • step-7: end

String Methods in Python with Examples

str1 = "welcome to all student" 
capital = str1.upper()
lower = str2.lower()
str3 = str2.replace("MITS","madanapalle")
str4 = "This is an example of strip"
left = str4.strip()
prefix1 = str1.startswith('hellow')
prefix2 = str1.startswith('wel')
prefix3 = str1.endswith('student')


String methods in python with examples

Recommended Post:

Pramod Kumar Yadav is from Janakpur Dham, Nepal. He was born on December 23, 1994, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India. Pramod has worked as the owner of RC Educational Foundation Pvt Ltd, a teacher, and an Educational Consultant, and is currently working as an Engineer and Digital Marketer.

Best PYthon Course

Get More trending Courses

Leave a Comment