Hi all. I'm making a program about 'reading and writing text files'
The assignment I have to do is suppose to look like this: http://i39.tinypic.com/5554wi.jpg

But I can't figure it how to make it so when it keeps looping until the user types in 'break' and it will list the names entered.

help, or brief explaination please? thank you!

while not blank:
    blank=("Enter your name or break to exit:")

y = open("pa16names.txt", "w")
x = raw_input("Enter your name or break to exit:")
y. close()  

y = open ("pa16names.txt", "r")
print "The names you've entered into the text file are:", y.read()

I was trying this out and I didn't get it to work yet either, but it seems like you could use a

while x != 'break':

and maybe an append(x) somewhere to help from writing over the previously entered names. I'll keep working on it.

Put the proper code inside the loop and it will work ...

fout = open("pa16names.txt", "w")

while True:
    name = raw_input("Enter your name (just Enter to exit): ")
    fout.writelines(name + '\n')
    if name == "":

fout. close()

fin = open ("pa16names.txt", "r")
print "The names you've entered into the text file are:"
print fin.read()
This question has already been answered. Start a new discussion instead.