1

I need to create a text file called Names_ages.txt using the following list

Josh 14   
Lauren 16   
Paul 18  
Mason 15  
Lily 17  
Stephanie 15  

If anyone can help me and understand how to create one, that would be greatly appreciated :)

Raj Paliwal
  • 943
  • 1
  • 9
  • 22

1 Answers1

0

This creates a text file from a list:

outfile = open("Names_ages.txt",'w')
name_list = ["Josh 14", "Lauren 16", "Paul 18", "Mason 15", "Lily 17", "Stephanie 15"]

outfile.write("\n".join(name_list))

Sam
  • 533
  • 3
  • 12