كلية التقنية اإللكترونية طرابلس
حاكمات دقيقة
Homework
Strip vs Split
االسم :أصيل عبد الكريم شعبان
رقم القيد192244 :
أستاد المادة :أ.أحمد الناجح
التاريخ21/1/2023 :
1|Page
Contents
➢ Strip method: ....................................................................................................................................... 3
➢ Split method: ........................................................................................................................................ 6
➢ Summary:.............................................................................................................................................. 9
2|Page
➢ Strip method:
Syntax: [Link]()
[Link](): Removes leading and trailing whitespaces (spaces,
tabs, and newline characters).
[Link](): Removes leading (left) whitespaces.
3|Page
[Link](): Removes trailing (right) whitespaces.
4|Page
[Link](“ ”): Removes leading and trailing of what is written
between the (“ ”)
[Link](“ ”): Removes the trailing of what is written between
the (“ ”)
[Link](“ ”): Removes the leading 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:
[Link](separator, maxsplit)
Parameter Description
separator Optional. Specifies the separator to use when splitting the
string. By default any whitespace is a separator
maxsplit Optional. Specifies how many splits to do. Default value is
-1, which is "all occurrences"
Basic split: (Whitespace as Default Separator):
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