Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8082117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:58:49+00:00 2026-06-05T16:58:49+00:00

python 2.7 how do you take any number and be able to compress it

  • 0

python 2.7

how do you take any number and be able to compress it to just lowercase letters and numbers? and how do you take the resulting string and put it back to the number?

doing something like chr() for each block of numbers of 3 numbers won’t work because if the block of number is bigger than 255, it will throw an error, and I only want lowercase numbers and letters.

edit:

the main purpose of this it to compress a number. the user will be seeing this and will be typing it in, so it needs to be easily typeable (can’t have weird characters that ascii supports but isn’t on a standard keyboard)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:58:51+00:00Added an answer on June 5, 2026 at 4:58 pm

    Use base 36, below is an adapted version of the Python implementation that you can find on Wikipedia:

    def base36encode(number, alphabet='0123456789abcdefghijklmnopqrstuvwxyz'):
        """Converts an integer to a base36 string."""
        if not isinstance(number, (int, long)):
            raise TypeError('number must be an integer')
    
        base36 = '' if number != 0 else '0'
        sign = ''
        if number < 0:
            sign = '-'
            number = -number
    
        while number != 0:
            number, i = divmod(number, len(alphabet))
            base36 = alphabet[i] + base36
    
        return sign + base36
    
    def base36decode(number):
        return int(number, 36)
    
    >>> print base36encode(1412823931503067241)
    aqf8aa0006eh
    >>> print base36decode('aqf8aa0006eh')
    1412823931503067241
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using import datetime in python, is it possible to take a formatted time/date string
I wrote a number crunching python code. The calculations involved can take hours. Is
I just started python, any suggestions would be greatly appreciated. I'm reading a table
I want to make a program in Python that can take video input from
Take for example the python built in pow() function. xs = [1,2,3,4,5,6,7,8] from functools
I'm working in python 2.6 and I would like to take gpmetisfile.txt.part.4 and return
I have two Python functions, both of which take variable arguments in their function
learning the basics of Python, now ready for a bigger challange... it didn't take
I have problem with python multithreaded Queues. I have this script, where producer take
I need help debugging some odd file behavior in Python. Take the following script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.