On 01/15/2013 09:31 PM, Gina wrote:
I have version 3

I am trying to read a text file ("the_file.txt") and then write a new file where the characters are in uppercase
but i don't know how/where i should use the .upper
I think i should use it where the ****** is, but i got errors when i tried that


text_file = open("the_file.txt", "r")
print(text_file.read())
text_file.close()

new_file = open("the_file_upper.txt", "w+")
new_file.write(*****)
print(new_file.read())
new_file.close()

Did you have a good reason to send a second identical message after waiting only 25 minutes for a response from the first? How about if you must do so, say SOMETHING new in the message, and make it a reply to the first, so they get threaded together and have the same subject line.

Anyway, your first problem is you never save any data from the first file. You're trying to do two very separate things in the same line. You read the data and immediately print it, without putting it any place you can reference it. Try something like:

indata = text_file.read()
print(indata)     #optional

Now, you can do something to indata before writing it to the output file. See how you get along with that.

Another point: If you get an error, be explicit. Show us what you tried, and quote the exact error (including the traceback of course). Otherwise it's like making an anonymous call to the police:

"Hello, somebody burglarized some house yesterday. Can you please tell me what they did with the toaster they broke?" And then hanging up immediately.

BTW, thanks for sending a text message instead of html.

--
DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to