Category Archives: Uncategorized

Using python read file line by line and create a list.

In this article we are going to see, How we can read a file line by line using python and create a python list with each line as a list element. There are many ways to do this task and in this article we are going to cover few of them. Suppose you are having a text file named “Text.txt” with following content. Line 1. Line 2. Line 3. Solution 1: Using for loop and append method. New_list = [] with open(“Text.txt”, “r”) as file: for

Read More

Python String Split method

In this article we are going learn about how python split method is used to split the string and produce a list. What is the syntax of python split. Sometimes we may want to break the long string and convert it into a small segments of strings. Python split is an action opposite to the string concatenation i.e in string concatenation we join multiple strings into one. Whereas using python split we can break the string into required segments. This purpose can be served using built-in

Read More