dimanche 24 mars 2019

TypeError: object of type 'int' has no len() *subtraction*

I'm trying to figure out if there's a way to make a small calculation by subtracting a variables number from 4

number_1_raw = random.randrange(1, 1000) number_1_len = len(number_1_raw) number_of_zeros = 4 - number_1_len print("0" * number_of_zeros + number_1_raw)

I wanted the script to give me an answer that ranged from 1-3, however the code isn't executing properly.

The desired output would be something like this: 0617 or 0071 or 0008, etc.

Please help with this issue, thanks!




Aucun commentaire:

Enregistrer un commentaire