new to ruby, help with simple output -
i trying learn ruby, , trying exercise on site , need learn ruby
write program asks number , sentence , prints sentence backwards many times. should:
puts "enter number?" repeathello = gets = 0 begin puts "hello world!" + end while > repeathello
you're making 2 mistakes in code pasted. first need add 1 each time loops. @ moment not increasing in value.
within loop (between begin , end) need increment so:
i += 1
(this shorthand = + 1).
the second mistake on last line. reads 'do while greater repeathello', starts @ 0, not going greater.
you need switch around to
while < repeathello.
you should end code this:
puts "enter number?" number = gets puts "enter sentence?" sentence = gets = 0 begin puts sentence.reverse += 1 end while < number
Comments
Post a Comment