It's a while loop and I need to add the log variable (most recent variable) to a list. I have no idea how to do it.
I'm going to add every number that is a multiple of both 5 and 7 (i.e. if x % 7==0
and x % 5==0
) to a list which I am going to state at the end.
But how?
--
"This program is about the find every number between 1500 and 2700 (inclusive) which is divisible by both 5 and 7"
x=1500
for x in range(1500,2701):
if x % 7==0 and x % 5==0:
print("\n", x,"IS DIVISIBLE\n")
x=x+1
#I THINK THE LIST STUFF GOES HERE
else:
print(x,"is not a common multiple")
x=x+1
input()
Basically, I just want the x
variable which is divisible by 7 and 5 (each time the loop runs) to be added to a list. E.g. 1505, 1540 etc.