Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to add list item to text file python

your_list = [1,2,3,'test']

with open('your_text_file.txt', 'w') as f:
    for item in your_list:
        f.write(f"{line}
")

# text file
1
2
3
test
Comment

PREVIOUS NEXT
Code Example
Python :: string of numbers to list of integers python 
Python :: python datetime round to nearest hour 
Python :: install aws sdk ubuntu 20.04 command line 
Python :: squared sum of all elements in list python 
Python :: python shuffle list 
Python :: pip install torch error 
Python :: how to open file in BeautifulSoup 
Python :: np array to df 
Python :: compute difference between two images python opencv 
Python :: pandas new column with loc 
Python :: django form password field 
Python :: create dataframe pyspark 
Python :: kivy fixed window 
Python :: how to make a discord bot delete messages python 
Python :: columns to dictionary pandas 
Python :: numpy remove rows containing nan 
Python :: apply format to pandas datetime column 
Python :: 2 - 20 python 
Python :: python read xls 
Python :: seaborn hue order 
Python :: selenium page down key python 
Python :: how to separate string in python by blank line 
Python :: tqdm notebook 
Python :: yesterday in python 
Python :: python convert latitude longitude to x y 
Python :: python join generators 
Python :: python import all words 
Python :: save dataframe to csv without index 
Python :: pandas drop values from column 
Python :: how to check if a string ends with a substring python 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =