'Encodes a URL to a shortened URL.
:type longUrl: str
:rtype: str'

def encode(self, longUrl):

    def getRand():
        rand = []
        for _ in xrange(self.__random_length):
            rand += self.__alphabet[random.randint(0, (len(self.__alphabet) - 1))]
        return ''.join(rand)
    key = getRand()
    while (key in self.__lookup):
        key = getRand()
    self.__lookup[key] = longUrl
    return (self.__tiny_url + key)
