0% found this document useful (0 votes)
36 views

Strings: Topics: String Class Associated Methods Examples

The document discusses strings in Python. It explains that strings can be defined using either single or double quotes. It then provides details on the string class and various associated methods that can be used to manipulate and check strings, such as capitalize(), count(), endswith(), lower(), and more. Examples of using these methods are also included.

Uploaded by

kiyara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Strings: Topics: String Class Associated Methods Examples

The document discusses strings in Python. It explains that strings can be defined using either single or double quotes. It then provides details on the string class and various associated methods that can be used to manipulate and check strings, such as capitalize(), count(), endswith(), lower(), and more. Examples of using these methods are also included.

Uploaded by

kiyara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

strings

 Topics:

 String Class

 Associated Methods

 Examples
Strings

Strings in python are surrounded by


either single quotation marks, or
double quotation marks

String Class
You can display a string literal with
the print() function:
print("Hello")
print('Hello')
Python has a set of built-in methods that you can use on strings.

capitalize()
Converts the first character to upper case
casefold()

String Converts string into lower case


center()

Methods Returns a centered string


count()
Returns the number of times a specified value occurs in a string

endswith()
Returns true if the string ends with the specified value
index()
Searches the string for a specified value and returns the
position of where it was found
isalnum()
Returns True if all characters in the string are alphanumeric

isalpha()

String Returns True if all characters in the string are in the alphabet

Methods isdecimal()
Returns True if all characters in the string are decimals

isdigit()
Returns True if all characters in the string are digits
islower()
Returns True if all characters in the string
are lower case
isprintable()

String
Returns True if all characters in the string
are printable

Methods isspace()
Returns True if all characters in the string
are whitespaces
Istitle()
Returns True if the string follows the
rules of a title
isupper()
Returns True if all characters in the string are upper
case
join()
Joins the elements of an iterable to the end of the
string

String lower()

Methods
Converts a string into lower case

lstrip()
Returns a left trim version of the string

rstrip()
Returns a right trim version of the string
strip()
Returns a trimmed version of the string

split()
Splits the string at the specified separator, and
returns a list

String rsplit()

Methods
Splits the string at the specified separator, and
returns a list
strartswith()
Returns true if the string starts with the specified
value
swapcase()
Swaps cases, lower case becomes upper case and
vice versa
title()
Converts the first character of
each word to upper case

String upper()
Converts a string into upper
Methods case
splitlines()
Splits the string at line breaks
and returns a list

You might also like