import random
import time
adding = input("Enter Name: ")
with open("settings.txt", "a+") as f:
f.write('\n'.join(i for i in adding.split() if len(adding.split(" "))>1 else adding))
data = a.readlines()
for line in data:
print (line)
time.sleep(10)
Try this. This prompts the user for input, splits that input across whitespace (so if I enter “Adam D. Smith” it returns [“Adam”,”D”,”Smith”]) if there’s more than one word, then sends each one to the textfile “settings.txt”, appending it to the end one line at a time, then reading the file back via data, reading it one line at a time.
>>>Enter Name: Adam D Smith
Adam
D
Smith
Is this the expected behavior?
7
solved Writing to another text file and more?