Advice with range function and or statements python
I am just trying to add up all the multiples of 3 and 5 up to 1000, while
making sure that I do not add the coinciding multiples twice hence the or.
I only want it to add the multiple of 5 if it is not a multiple of 3.
Thanks in advance
a=range(0, 1000,3 ) or range(0,1000,5)
b=sum(a)
print (b)
No comments:
Post a Comment