0

What does upper() do here?

def print_formatted(number):
    max_width = len(bin(number)[2:])
    for i in range(1,number+1):
        print(str(i).rjust(max_width)  + " " +oct(i)[2:].rjust(max_width) + " " +(hex(i)[2:].upper()).rjust(max_width) + " " +bin(i)[2:].rjust(max_width))
        

    
    
    

if __name__ == '__main__':
    n = int(input())
    print_formatted(n)

I understood all code, I just didn't understand what upper() does in this specific code. I'm a beginner

  • https://docs.python.org/3/library/stdtypes.html#str.upper – user2357112 Jan 13 '23 at 01:34
  • Did you perhaps try a web search for "python upper function"? – John Gordon Jan 13 '23 at 01:35
  • Welcome to Stack Overflow. For simple "what does this thing do?" questions, there are many tools you can [and should](https://meta.stackoverflow.com/questions/261592) use to help yourself first. For example: did you try to use the `upper` function by itself? Did you try to look for it in the documentation? Did you try to read the built-in documentation provided by Python, by running `help(str.upper)`? Did you try to [use a search engine](https://duckduckgo.com/?q=Python+upper()+function)? – Karl Knechtel Jan 13 '23 at 01:37

0 Answers0