28.10.2021 Views

Python Tutorial ( PDFDrive )

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

this is string example....wow!!!

swapcase()

Description

The method swapcase() returns a copy of the string in which all the case-based characters have had their case

swapped.

Syntax

Following is the syntax for swapcase() method:

str.swapcase();

Parameters

• NA

Return Value

This method returns a copy of the string in which all the case-based characters have had their case swapped.

Example

The following example shows the usage of swapcase() method.

#!/usr/bin/python

str = "this is string example....wow!!!";

print str.swapcase();

str = "THIS IS STRING EXAMPLE....WOW!!!";

print str.swapcase();

Let us compile and run the above program, this will produce the following result:

THIS IS STRING EXAMPLE....WOW!!!

this is string example....wow!!!

title()

Description

The method title() returns a copy of the string in which first characters of all the words are capitalized.

Syntax

Following is the syntax for title() method:

str.title();

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!