Section 4.3 step 11

Thanks I got! My range of numbers was wrong.

1 Like

i cant seem to get this correct for anything. I have 5 failed attempts

Edit: per our posting guidelines, please do not post significant amounts of code or solutions outside of private mesaages. Thanks!

Remember that a range (a,b) does not include the number for b, but rather (b-1).

I understand the range and the use of the modulus but somehow I am still not getting it. I’m confused as to how to include both of them. When you ask about indenting I don’t know how I would do that.

1 Like

Indenting happens with 4 presses of the space bar. It is used, among other things, to designate code within a loop. You might try using the modulus function within a loop defined by the range function.

For this problem, you’re working in fill-in-the-blanks, so you don’t have to worry about indenting. If you’re sure about how you’re using range and modulus, the other spots I see people tripping up are the conditional for hooray and the printing syntax.

Try copying and pasting your best guess into the previous step’s and see what it prints out; if you get an error message, that should point you in the right direction of what to fix, otherwise, compare your output to the expected output below that terminal window and see if they match. If they don’t match, walk through each number and see where the difference could be coming up.


Can someone give me a hand? I am not sure where I am making my mistake :frowning

Never mind I got it! :slight_smile: :

Even i failed more than 10 times…but your concept of changing the range worked. thanks

I’m absolutely stuck on this step. Can someone please walk me through it? Thanks

Some common sticking points: 1. If a “range” is used, please remember that it does not include the last number listed. ie ( for elem in range (1,35) would NOT include 35, but would end at 34. That trips lots of folks up. Also, remember how a modulus (%) function works-- if 2 is a factor of, for example, 8, then ( 8 % 2 ) == 0.

Hello! I’m also getting an error on Section 4.3 step 11. I used the same code that I did in 4.3 step 10 and got the code to successfully run with “Hip Hip Hooray” continuously as the output. However, when I filled in the blanks on step 11 I keep getting incorrect answers.

the code I wrote was:

code removed, please do not paste large sections of code

Again, when I put this code into 4.3 Step 10, I get the correct output without any syntax errors, however when I fill in the blanks on Step 11. I keep getting the wrong answer. Can anyone advise me? Trying to get finished by tonight! Thank you!

I think the only difference between mine and yours is for number in range() I actually put three numbers in it, the last one was how much I wanted increment per loop. I don’t know if it makes any difference for this one.

Thanks for the reply! I figured it out. I had to change it to 1 in the beginning of the range. Which is what I originally had, but I didn’t have the “” around Hip and Hooray the first few thousand times

Thanks, Adam! This helped. I was so frustrated because my code was working, but I couldn’t get the right answer for the fill in the blanks.

I cannot get this not matter what I try… if 13% are getting it correct on the first try, maybe it’s a bad question

This fixed my problem. I got quite a few incorrect submissions this module. Glad to see I wasn’t the only one.

Really struggling to fill in the blanks here, i have put the range from 1, 41 but nothing seems to be working.

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

This is what I have put together.

1 Like

The elif is not necessary, as there might be cases where the number is divisible by both 3 and 7. I would keep them both as “if” statements. Also, you should not have to put the final “1” in your range, your stepper, in that if there is no designation, the stepper is automatically “1”.

1 Like

THANK YOU. I did not realize you can have multiple “if” statements without “else” statements. Game changer!

You bet. You can have many of them.