Take two numbers (separated by a space) as user input in a single line
which will be used as a range (both numbers inclusive) later. Your task is
to create and print a Python dictionary where the keys will be numbers from
that range and the corresponding values will be the odd factors (divisors)
of that number in a tuple.
m, n = input().split()
m, n = int(m), int(n)
if m > n:
m, n = n,m
res = {}
for i in range(m, n+1):
tmp = tuple()
for j in range(1, i+1, 2):
if i%j == 0:
tmp = (*tmp, j)
res[i] = tmp
print(res)
Comments
Leave a comment