5 More Python String Built in Method

5 More Python String Built in Method

1) isupper()?

Working: It will return true if all the character in string are upper case otherwise false will return. It used to check, whether string is in upper mode or not.

Syntax:

string.isupper()

Example:

str = “RUSHIKESH”

str1 = “hOW aRe yoU”

print(str.isupper())

print(str1.isupper())

Result:

True

False


2) replace()

Working: It used to replace one character or set of character to other

Syntax:

string.replace(old, new)

Example:

str = “How are you ali”

x = str.replace(“ali", “rushikesh")

print(x)

Result:

How are you rushikesh


3) index()

Working: It used to find index number of any character or set of character in a specific string. It return index number

Syntax:

string.index(char or set of char)

Example:

str = "rushikesh Website"

x = str.index("Website")

y = str.index("h")

print(x)

print(y)

Result:

10

3


4) title()

Working: Title method is used to convert first character of each world to uppercase and remaining character will be in lowercase.

Syntax:

string.title()

Example:

str = “rUshikesh rEddy”

result? = str.title()

print(result)

Result:

Rushikesh Reddy

5) isspace()?

Working: It will return true, if all the character are white spaces. It find only whitespace in a string. If any one character in non whitespace then it return false.

Syntax:

string.isspace()

Example:

str = “ ”

str.isspace()

Result:

True

要查看或添加评论,请登录

Rushikesh J.的更多文章

  • Linux Operating System

    Linux Operating System

    Linux Operating System ======================= => Linux is a community based OS => Linux is free & Open Source => Linux…

  • Infrastructure

    Infrastructure

    ================= Infrastructure ================= Servers (Machines) Databases Storage Network Security Backup =>…

  • Application Architectural Patterns

    Application Architectural Patterns

    =================================== 1) Monolithic Architecture (Outdated) 2) Microservices Architecture (Trending)…

  • DevOps Introduction

    DevOps Introduction

    =============== What is DevOps =============== DevOps = Development + Operations => DevOps is a culture/process in IT…

    2 条评论
  • Try and Exception in Python

    Try and Exception in Python

    Exception is the error and is an event, which occur when program statements are executing. It disrupts the flow of…

  • Python Array With Examples

    Python Array With Examples

    Array in Python Array in Python Array is the collection of items having same data type with contiguous memory location.…

  • Python Date Object

    Python Date Object

    We can work with time and date with Python. There are two module in Python time and datetime that used to work with…

  • String Formatting WITH Problems and Solution

    String Formatting WITH Problems and Solution

    What is String Formatting? It is the way to insert custom string or variable in a text (string). Using string…

  • SET Different Methods With Examples

    SET Different Methods With Examples

    SET Method : add() Working: This method is used to add element to set. Syntax: set.

  • Python SET Comprehension With Examples

    Python SET Comprehension With Examples

    What is Comprehension? ?We create a sequence from a given sequence is called comprehension. ?Sequence means list…

社区洞察

其他会员也浏览了