Skip to content Skip to sidebar Skip to footer

Python 2.7.6 Isupper Function In If/elif/else Statements

I need help with the str.isupper() function. I am trying to use it in an if/elif/else statement. The program is this. String = raw_input( 'Please enter a string. ') if String[:1].i

Solution 1:

The print statement required two minor corrections:

String = raw_input( 'Please enter a string. ')
ifString[:1].isupper():
    print'The first character,' + String[0] + ', is capitalized'

The first was that String needed to be capitalized. and the second was to remove the parentheses.

MORE: Here is the code with a working if/else statement to show both cases:

String = raw_input( 'Please enter a string. ')
ifString[:1].isupper():
    print'The first character, ' + String[0] + ', is capitalized'else:
    print'The first character, ' + String[0] + ', is not capitalized'

Post a Comment for "Python 2.7.6 Isupper Function In If/elif/else Statements"