![]() |
Python String splitlines() method is used to split the lines at line boundaries. The function returns a list of lines in the string, including the line break(optional).
splitlines() splits on the following line boundaries:
Example 1Python3
Output: ['Welcome everyone to', 'the world of Geeks', 'GeeksforGeeks'] ['Welcome everyone to', 'the world of Geeks', 'GeeksforGeeks'] ['Welcome everyone to\r', 'the world of Geeks\n', 'GeeksforGeeks'] Example 2Python3
Output: ['Cat', 'Bat', 'Sat', 'Mat', 'Xat', 'Eat'] ['India', 'Japan', 'USA', 'UK', 'Canada'] Example 3: Practical ApplicationIn this code, we will understand how to use the concept of splitlines() to calculate the length of each word in a string. Python3
Output: ['Welcome', 'to', 'GeeksforGeeks'] [7, 2, 13] |
Reffered: https://www.geeksforgeeks.org
Python |
Related |
---|
![]() |
![]() |
|
|
|
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |