''' Purpose: consider string casing functions ''' text = input( "Enter text: " ) print() print( "text:", text ) print() # produce case variants of input text text_c = text.capitalize() text_l = text.lower() text_u = text.upper() print( "text.lower():", text_l, " # all lower case" ) print( "text.upper():", text_u, " # all upper case" ) print( "text.capitalize():", text_c, " # initial character capitalized, rest lower case" ) print() # WRITE THIS DOWN: STRINGS ARE IMMUTABLE (cannot change the original string -> these functions # hand back a VERSION of the string with the function applied in it which is why we store them in # variables!) # variable = s.function() ex. text_c = text.capitalize() # THREE NEW FUNCTIONS FOR STRINGS (DOES NOT CHANGE s) # s.capitalize() # Capitalizes the first character of a string and makes everything else lowercase # s = 'naDIa' # s.capitalize() -> 'Nadia' # s.lower() # Makes all the characters lowercase # s = 'COHOON' # s.lower() -> 'cohoon' # s.upper() # Makes all the characters uppercase # s = 'ann' # s.upper() -> 'ANN' # STORE THE FUNCTION CALLS IN ANOTHER VARIABLE! ^^ # Ex. capitalized_name = s.capitalize() -> 'Nadia' # s retains the original value!