Split Vs Strip
Split Vs Strip
Split Vs Strip
حاكمات دقيقة
Homework
Strip vs Split
التاريخ21/1/2023 :
1|Page
Contents
➢ Strip method: ....................................................................................................................................... 3
➢ Split method: ........................................................................................................................................ 6
➢ Summary:.............................................................................................................................................. 9
2|Page
➢ Strip method:
Syntax: str.strip()
3|Page
str.rstrip(): Removes trailing (right) whitespaces.
4|Page
Str.strip(“ ”): Removes leading and trailing of what is written
between the (“ ”)
5|Page
➢ Split method:
function in Python is a string method that is used to split a string into a list
of substrings based on a specified delimiter.
Syntax:
string.split(separator, maxsplit)
Parameter Description
6|Page
• splitting with a custom separator:
7|Page
• Specifying the Maximum Number of Splits:
8|Page
• Splitting Lines in a Multiline String:
➢ Summary:
Strip() Split()
split() is used for breaking is used for breaking a string
Used For: a string into substrings, into substrings, typically
typically based on a based on a specified
specified separator,
Application: For example: The split() method
User Input Validation is commonly used
and data cleaning in when dealing with
text data, such as
files
parsing CSV files or
breaking down
sentences into
individual words.
9|Page