In 9/13 even though I am sure I have fallowed the instructions correctly codcadomy


#1

for i in 0..18
next if i / 2 == 0
print i
end

is this correct codecadomy?!?!?!?!?!?!??!??!??!??!?!?!?!?!??!?!??!?!?!? huh


#2

Could you provide the lesson number or instructions in the lesson?


#3

I've tried

 for i in 0...20
 next if i % 2 == 1
 print i
 end

and

for i in 0..18
next if i % 2 == 1
print i
end

and

i = 20
while i != -1
  i -= 1

  next if i % 2 == 1

  puts "#{i}"
end

I'm getting the same error over and over: Oops, try again. It looks like your loop doesn't print out the numbers 18 to 0.

The exercise is in "Looping with Ruby", section 5. Loops & Iterators, number 9. Next.

Need a help here too.

[edit]
Sorry, problem solved. I've write puts and the exercise required print. Not so flexible. =/


#4

This is what I did,

i = 20
loop do
i -= 1
next if i % 2 != 0
print "#{i}"
break if i <= 0
end

If 1 % 2 == 0 skipped the even numbers then 1 % 2 != 0 skips the odds.


#5

I tried that and got a message saying false (!) statements are not allowed in this. 1% 2 = 0 means that when i is divided by 2 it has no remainder (i.e. is an even number), the answer has to be that the if i is divided by 2 there is a remainder, which means the change to the string is not before, but after the =. the code that works is next if i % 2 == 1


#6

i dont mean to but can you at least learn how to spell correctly? "fallowed" is followed, "codcadomy" is codecademy!


#7

Hardly anyone does that. I know it is annoying.


#8

Thanks ..!! this one helped me


#9

To me the question became unclear when I first tried the problem. After a few unsuccessful attempts and seeing the error alert, I found the below block of codes helpful:
i = 20
loop do
i -= 1
next if i % 2 != 0
print "#{i}"
break if i <= 0
end


#10

I am stuck here, any hints

i = 20
loop do
i -= 1
print "#{i}"
next if i % 2 == 0
break if i <= 0
end