Я пытался создать программу, которая принимает число в качестве ввода и отображает его в виде списка. Программа:
# we ask for input
num = int(input('enter the number of which you would like to find prime factors of\n='))
div_list = [] # we create an empty list to store all the divisors of the number
prime_div = [] # we create a list for all the prime divisors
for _ in range(2, num-1): # we check all the divisors
if num % _ == 0:
div_list.append(_) # we add all the divisors to the list
for i in range(len(div_list)): # this loop will run the next loop for the duration of all the nums
for j in range(2, div_list[i]):
if div_list[i] % j == 0:
pass
else:
prime_div.append(div_list[i])
print('the list of all the prime factors is')
print(prime_div)
, но когда я запускаю эту программу, она дает мне ввод только 1 цифры.:
enter the number of which you would like to find prime factors of
=49
the list of all the prime factors is
[7, 7, 7, 7, 7]
Я не понимаю, почему это происходит.Есть идеи?