I need help in this code. I want to separate the given details using the newline but this is the output I'm getting.
John 12-12345January 1, 1990Unknown
How do I separate this to:
John
12-12345
January 1,1990
Unknown
This is my code:
while True:
f = open("Personal details of the students", "wt ")
f.write(str(input("PLease enter your name: ")))
f.write(str(input("Please enter your Student Number: ")))
f.write(str(input("Please enter your birthday: ")))
f.write(str(input("Please enter your complete adress: ")))
next_fill = input("Do you want to try again? Y|N: ")
if next_fill[0] in "Yy":
continue
elif next_fill[0] in "Nn":
print("Thanks for filling out the form. Have a nice day.")
break
f.close()
Thanks guys for the help!
CodePudding user response:
A simple fix is to add a \n
after the user input:
f.write(str(input("PLease enter your name: ") "\n"))
f.write(str(input("Please enter your Student Number: ") "\n"))
f.write(str(input("Please enter your birthday: ") "\n"))
f.write(str(input("Please enter your complete adress: ") "\n"))