Python Forum

Full Version: multiples of 3, smaller than 100
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!!
I have some tasks I need to do (not real HW, it's more like tasks to help me understand python from a classmate)
1. Code a program that writes multiples of 3 which is smaller than 100 in a file named multi.txt.
2. Code a program that adds multiples of 7 which is smaller than 100 in the file you created above.

Since I'm quite new to python I'm not really sure how to start with this? I know I probably need the range function and a loop... but how exactly do I write it?

I found this code, but it prints the sum which I don't need..
I've been googling all day but apparently it's too easy to find a solution for it lol

n = 101
sum = 0
for i in range(1,n,3):
    sum = sum + i
print (sum)
Can someone please help me out..
your print statement needs to be indented to same level as sum = ...