Discovery program 4.3 question 10-11

Question: write a program that loops through the numbers between 1 and 40. If a number is divisible by 3, print Hip. If the number is divisible by 7, print Hooray.

Hint: use a range function instead of hard coding all the numbers

I keep getting stuck on this problem and the code I’ve been trying keeps printing a syntax error.

my code:
for number in range(1,41):
if n%3==0
if number % 7== 0

the error states that the syntax in line 3 is invalid but i googled it and every other python user puts that syntax so idk what I’m doing wrong

Update: I solved it. All I needed was colons after ‘if number%7==0’ and to go to sleep lol

1 Like