Oct-06-2022, 08:56 AM
Hi,
i have to draw int number from (1000, 9999) and create new number where I have to change units with tens and hundreds with thousands from the first number, Im new in python so it has to be done in the simplest way. I have something like this:
i have to draw int number from (1000, 9999) and create new number where I have to change units with tens and hundreds with thousands from the first number, Im new in python so it has to be done in the simplest way. I have something like this:
import random from typing import Final RANGE_MIN: Final[int] = 1000 RANGE_MAX: Final[int] = 9999 n = random.randint(RANGE_MIN, RANGE_MAX) print(f'{n = }') units = int((n // 10 ** 0) % 10) tens = (n // 10 ** 1) % 10 hundreds = (n // 10 ** 2) % 10 thousands = (n // 10 ** 3) % 10 print(f'{units = }\n{tens = }\n{hundreds = }\n{thousands = }')Now i dont know how to create the new number