python capitalize first letter only
I am aware .capitalize() capitalizes the first letter of a string but what if the first character is a integer? this 1bob 5sandy to this 1Bob 5Sandy 10 Answers 10
I am aware .capitalize() capitalizes the first letter of a string but what if the first character is a integer? this 1bob 5sandy to this 1Bob 5Sandy 10 Answers 10
I am using Java to get a String input from the user. I am trying to make the first letter of this input capitalized. I tried this: String name; BufferedReader br = new InputStreamReader(System.in); String s1 = name.charAt(0).toUppercase()); System.out.println(s1 + name.substring(1)); which led to these compiler errors: Type mismatch: cannot convert from InputStreamReader to BufferedReader … Read more
s=”the brown fox” …do something here… s should be: ‘The Brown Fox’ What’s the easiest way to do this? 22 s 22 The .title() method of a string (either ASCII or Unicode is fine) does this: >>> “hello world”.title() ‘Hello World’ >>> u”hello world”.title() u’Hello World’ However, look out for strings with embedded apostrophes, as … Read more
How do I make the first letter of a string uppercase, but not change the case of any of the other letters? For example: “this is a test” → “This is a test” “the Eiffel Tower” → “The Eiffel Tower” “/index.html” → “/index.html” 11 117
String str = “java”; String cap = str.substring(0, 1).toUpperCase() + str.substring(1); // cap = “Java” With your example: public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // Actually use the Reader String name = br.readLine(); // Don’t mistake String object with a Character object String s1 = name.substring(0, 1).toUpperCase(); … Read more