Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with acroym creating
#1
I have a homework question that states the following:

An acronym is a word formed by taking the first letters of the words in a phrase and making a word from them. For example, RAM is an acronym for “random access memory.” Write a well-documented Python program that allows the user to type in a phrase and then outputs the acronym for that phrase. The acronym should be all uppercase, even if the words in the phrase are not capitalized.

But I'm stuck on it, I don't know if I am doing it right but this it was I have so far

#Ask for word
w = input("Type in word to create acronym with spaces between the words")

#Seperate the words to create acronym

s = w.split(" ")
letter = s[0]




#print answer

print s.upper(letter)
Reply
#2
You are on the right track!

Let's split the problem up into smaller pieces. If you have a word, e.g. 'test', do you know how to get the corresponding letter (in this case 'T')?
Reply
#3
You've got the first letter of the first word, you just need to loop over the words to get the first letter of each word. The loop would start with for word in w.split():.

Note that your task is to create a "well documented" Python program. I would not consider a program with one letter variable names to be well documented.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020