How To Write Upper Function In Python