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