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:

Hi, I’m Pramod Kumar Yadav & a computer science Engineer with 3years of experience in Digital marketing. I’m self-motivated and love to do SEO.

Best PYthon Course

Get More trending Courses

Leave a Reply

%d bloggers like this: