Search code examples
pythonhashnumberstrim

How can I trim only (10) numbers in Python


hashCode = 0x39505b04f1c2e5c03ea3

I want to see only 10 characters, How ?


Solution

  • If you want to see the first 10 characters:

    hashCode = '0x39505b04f1c2e5c03ea3'
    
    print(hashCode[:10])
    

    outputs:

    '0x39505b04'
    

    If you want to instead see the last 10 characters:

    hashCode = '0x39505b04f1c2e5c03ea3'
    
    print(hashCode[10:])
    

    outputs:

    'f1c2e5c03ea3'