Oct-16-2022, 02:36 PM
(This post was last modified: Oct-16-2022, 02:43 PM by astral_travel.)
alright ! i got it !
okay i have another question:
when i execute the following code:
i mean, why doesn't it just write the last result ? (the last line) ?
like, simply: [2, 3, 5, 6, 10, 15, 30]
okay i have another question:
when i execute the following code:
user_number = int(input("please choose a number to check: ")) list1 = range(2, user_number+1) list2 = [] for x in list1: if user_number % x == 0: list2.append(x) print(list2)it gives me the following output:
Output:please choose a number to check: 30
[2]
[2, 3]
[2, 3, 5]
[2, 3, 5, 6]
[2, 3, 5, 6, 10]
[2, 3, 5, 6, 10, 15]
[2, 3, 5, 6, 10, 15, 30]
Process finished with exit code 0
now, why does it give me the whole process of getting to 30 ?i mean, why doesn't it just write the last result ? (the last line) ?
like, simply: [2, 3, 5, 6, 10, 15, 30]