Support Forums

Full Version: Beginner's Python help!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am a beginner to python and struggling already! (WAH!)

I have a question on a practice worksheet which I cannot crack. In fact, I'm not getting anywhere close to a solution!
______________________________________________________________

A variable name stores the name of a person with the title (in capitals) as given in their credit card. Write a program which displays a greeting "Good day M'am!" or "Good day Sir!" depending upon whether MS or MR was used in the title. If no title was given in the input, your program should print an error message (Please specify the title in capitals in the input..)


name = 'MR SAM WOODBRIDGE'
The output of your program should be 'Good day Sir!'

name = 'MS AMY PARKER'
The output of your program should be 'Good day M'am!'

name = 'AMY PARKER'
The output of your program should be 'Please specify the title in capitals in the input.'


______________________________________________________________

So far I have figured that this will involve the use of lists, strings and the if/elif/else functions. However, I keep getting endless amounts of error messages.

I am able to get the if/elif/else function to work with other programs which are just using numerical values, but as soon as sentences are involved, I struggle. How do I implement these sentences and titles to the program properly?