-4

I created a .txt file with random words that I'm importing into my script. I want then to take all the words, print one on each line and convert them all to uppercase. I have the first part done:

a=open("redchief.txt").read().split()

print ' \n'.join(a)

I'm having problems converting the data into capital letters. Here is some of the data:

It looked like a good thing: but wait till I tell you.
jscs
  • 63,694
  • 13
  • 151
  • 195
Dustin Hunt
  • 7
  • 1
  • 1
  • 3
  • I know how to do it if I did s = asdf then did s.upper() but I'm having problem since I'm reading in a file. Maybe I'm making it too complicated. I read that post before I posted. I didn't want to make a duplicate. – Dustin Hunt Jun 16 '13 at 21:46
  • 2
    You've gotten pretty far on your own; that's good! Your problem statement is very vague, though. If you've read that post and tried something, please edit your question to be more specific about what the trouble is and what you're not understanding. – jscs Jun 16 '13 at 21:47
  • Why is it a problem if you read in a file? – oliver13 Jun 16 '13 at 21:47
  • It looks like `"It looked like a good thing: but wait till I tell you."` is the sentence from your file, right? So you are not using a random words in terms of CS random. If so, you are NOT calling upper() as @JoshCaswell wrote... – Betlista Jun 16 '13 at 22:11

1 Answers1

0

Just change your last line from:

print ' \n'.join(a)

to:

print ' \n'.join(a).upper()

you don't have to store the result in a separate variable first, since ' \n'.join(a) gives you a string object whose upper() method you can call.

Crowman
  • 25,242
  • 5
  • 48
  • 56