PYTHON – STRING,
LIST ,TUPLE, DICT
MANIPULATION
Module
FUNCTION
LIST
FUNCTIONS
Python has a set of built-in methods that
you can use on lists
LIST
FUNCTIONS
Python has a set of built-in methods that
you can use on lists
LIST
FUNCTIONS
Python List append()
Method
The append() method appends an
element to the end of the list.
LIST
FUNCTIONS
Python List append()
Method
LIST
FUNCTIONS
Python List clear()
Method
It is used to clear/empty
the list.
LIST
FUNCTIONS
Python List clear()
Method
The clear() method removes
all
the elements from list.
LIST
FUNCTIONS
Python List insert() Method
The insert() method inserts the specified
value at the specified position.
STRING
FUNCTIONS
lower(): Converts all uppercase
characters in a string into lowercase
upper(): Converts all lowercase
characters in a string into uppercase
title(): Convert string to title case
swapcase(): Swap the cases of all
characters in a string
capitalize(): Convert the first character of
a string to uppercase
STRING
FUNCTIONS
Example: Changing the case of Python
Strings
STRING
FUNCTIONS
Example: Changing the case of Python
Strings
STRING
FUNCTIONS
Example: Changing the case of Python
Strings
O/P:
STRING
FUNCTIONS
Python String count() Method
Python String count() function returns the
number of occurrences of a substring
within a String.
STRING
FUNCTIONS
Python String count()
Method
O/P:
STRING
FUNCTIONS
Python String isalnum() Method
Python String isalnum() method checks
whether all the characters in a given string
are either alphabet or numeric
(alphanumeric) characters.
Syntax: string_name.isalnum()
True: If all the characters are alphanumeric
False: If one or more characters
are not alphanumeric
STRING
FUNCTIONS
STRING
FUNCTIONS
String isalpha() in Python
Example
STRING
FUNCTIONS
Python String lstrip() method
Python String lstrip() method returns a
copy of the string with leading characters
removed (based on the string argument
passed).
If no argument is passed, it
removes leading spaces.
STRING
FUNCTIONS
STRING
FUNCTIONS
Split a String
It is a very common practice to split a
string into smaller strings. In Python, we
use the split() function to do this. It splits
the string from the identified separator
and returns all the pieces in a list.
Syntax:
string.split(separator, maxsplit)
separator: the string splits at this separator.
maxsplit (optional): tells how many splits to do.
STRING
FUNCTIONS
STRING
FUNCTIONS
join() Function
This method is used to join a sequence of
strings with some operator. The join()
operator will create a new string by
joining every character of the sequence
with a specified character, including
whitespaces.
STRING
FUNCTIONS