upper() is a Python string method that returns an uppercase copy of a string. Call it with parentheses, as in word.upper(); word.upper without parentheses refers to the method itself rather than executing it. section 2.1.9
Convert and test a word
>>> word = 'narwhal' >>> word.upper() 'NARWHAL' >>> word 'narwhal' >>> word.upper().isupper() True The original string remains unchanged, so the returned value can be printed, assigned, or passed to another string method. section 2.1.9
Use upper() when uppercase text helps normalize input or produce output:
- Check a first character without separately handling uppercase and lowercase input, such as testing whether word[0].upper() belongs to a collection of letters. section 2.1.13
- Write transformed text to a file with out_fh.write(text.upper()) or print(text.upper(), file=out_fh). section 5.5.4
- Create uppercase dictionary keys while reading lines with lookup[line[0].upper()] = line.rstrip(). section 7.3.2
Inspect the interactive example showing upper() called on a string and producing uppercase output. section 2.1.9

