probabilmente ti conviene modificare il test if n<0: n=0
con un if n<=0: return "0" Il giorno mar 15 nov 2022 alle ore 14:06 <iz4...@libero.it> ha scritto: > > Ciao a tutti. > > Ho questa funzione che scrissi 9 anni fa con l'aiuto di uno di voi della > lista, Federico Figus, che converte un qualsiasi intero in una stringa in > base 62: 10 cifre + 26 lowercase + 26 uppercase. > > Il problema è che se passo uno 0, non mi restituisce "0" come dovrebbe, ma > una stringa "". > > > > Qualcuno vede il perché? > > > > def base62(n): > > '''Converte un intero in base 10 ad una stringa in base 62. > > Author: Federico Figus > > Modified by Gabriel Battaglia Kriyaban 9/5/2013 > > Version 2, 15/11/2022 > > ''' > > import string > > b = string.digits+string.ascii_letters > > n=int(n) > > if n<0: > > n=0 > > out = [] > > while n: > > out.append(n%62) > > n = int(n/62) > > return ''.join(b[l] for l in out)[::-1] > > > > Gabriele Battaglia (Gabe / Gabry) - IZ4APU > > --... ...-- -.. . .. --.. ....- .- .--. ..- - ..- . . > > Sent from Outlook on Windows, Genus Bononiae's computer. (Libero) > > > > _______________________________________________ > Python mailing list > Python@lists.python.it > https://lists.python.it/mailman/listinfo/python -- !!!! THE 🍺-WARE LICENSE (Revision ㊷): <miron🐌🐍.🇮🇹> wrote this 📧. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a 🍺 in return. — Carlo _______________________________________________ Python mailing list Python@lists.python.it https://lists.python.it/mailman/listinfo/python