I was asked to capitalize the first letter of each word in a sentence and return the number of letters that have been capitalized. I have this so far:
text = input('Enter a sample text:\n')sentence = text.split('.') for i in sentence: print (i.strip().capitalize()+". ",end='')
I just need to figure out how to count how many times a letter has been capitalized.
I am really just starting programming with python and I have a small program that responds to certain user input. I would like to have it so that when you type in something that is capitalized it doesn't matter whether it is capitalized in the code. This is the code I have written so far.
I can't add an image because I don't have enough rep but I think I can explain it.
So this is the code that I have at the moment
Loops and responds to specific user input
import randomBOO = ("Aghh!", "That wasn't just a fart!", "Oh, I was soo scared", "I am so terrified right now", "Where did you spring from?!", "If this was any more scary it would be R rated!")x = ""print "I am a simple computer program designed to respond to certain inputs from a user"x = raw_input("Input: ")while not(x == "exit" or x == "Exit"): if x == "Oli" or x== "oli" or x == 'Oliver' or x == 'oliver': print "Its the creator!" elif x == "hi" or x == "hello" or x == "Hi" or x == "Hello": print "Hi!" elif x == "how are you?" or x == "how are you": print "Fine thanks!" elif x == "boo!" or x == "boo" or x == "BOO!" or x == "Boo": print random.choice(BOO) elif x == "You are actually awesome": print "Aww, Thanks!" else: print "Hello, " + x x = raw_input("Input: ")
For example: On line 21 where the user inputs the word "boo" I have had to add an or statement for the different capitalization of the world. Is there a way that the code can check for capitalization and still print the same output (or randomised)I have checked over stackoverflow yet I cannot find the answer to my problem. Thankyou.
I have a String and I need to convert the first letter of each word to upper case and rest to lower case using xsl, For example,
Input String= dInEsh sAchdeV kApil Muk
Desired Output String= Dinesh Sachdev Kapil Muk
Although, I know I have to use translate function for the purpose but how can I translate the first charter of each word to Upper-case and rest all in lower- case using XSLT 1.0
I am using titleForHeaderInSection to show a header for a UITableView section. It worked fine with the iOS6 SDK, but the iOS7 SDK shows the header in all CAPS.
I guess it's part of Apple's updated Human Interface Guidelines; all examples in there show headers in all caps. Also, all section headers in Settings on my iPhone are in all caps.
However, I wonder if there is a way around that. Normally, I wouldn't mind showing caps if that improves consistency, but when I need to show people's names in a section header, it's a bit awkward.
Anybody any idea how to get around to capitalization?
def initials(text): result=bla bla blareturn result
text=input("Please enter your text")initials(text)