Ruby Looping with "While"


#1

https://www.codecademy.com/en/courses/ruby-beginner-en-XYcN1/3/1?curriculum_id=5059f8619189a5000201fbcb

The code works, but there are still error messages. It says "Oops, try again. It looks like you didn't print out the numbers 1 to 50, inclusive."

i = 1
while i <= 50 do
    puts i
    i += 1
end

#2

@ebumper,
They want you to use the print statement ( all numbers on 1 line )
instead of you using the puts statement ( all numbers on a separate line )


#3

yeah I ran into the same issue before codecademy is real specific about how you return and enter in code sometimes. The code is good and works fine, but for that project they want you to to return with print instead of puts, That way it doesn't create a new line for each output.


#4

@cfecteau1,
Codecademy lessons try to introduce you to Ruby via example's.....
You will still have to do some == Book == reading

Reference
https://www.ruby-lang.org/en/documentation/

https://en.wikibooks.org/wiki/Ruby_Programming
https://en.wikibooks.org/wiki/Ruby_Programming#Ruby_language
http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/index.html

http://docs.ruby-lang.org/en/2.0.0/Object.html
http://docs.ruby-lang.org/en/2.0.0/Array.html
http://docs.ruby-lang.org/en/2.0.0/String.html
http://docs.ruby-lang.org/en/2.1.0/Hash.html

To get article's on
== discussions / opinions ==
ruby [your question] site:stackoverflow.com


#5

I understand that, I was just meaning that you have to watch how to enter your code and output it. Thank you for the info, but i am already familiar with many of those sites and have read a few books so far. I know that Codecademy is mainly for beginners and you have to do more than just a few examples to learn to program. I have been through lots of different training sites and tutorials and read lots of books on many different subjects. I have been teaching myself slowly for the last year starting with html and css and now onto ruby and javascript. The fact of whether or not you output using puts or print is purely a preference as to how you want the code to appear. you could also print on separate lines by including "\n". I thank you for the pointers, but honestly it seemed as though you were trying to insult me, if not than sorry for taking it that way and if so sorry as well.


#8

A post was split to a new topic: https://github.com/karan/Projects


#9