More methods, more solutions question

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

Dear community,

Could someone please explain to me the difference between the below two lines of code and why the exercise only approves of one of the two?

Thanks

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/ruby-beginner-en-Qn7Qw/2/5?curriculum_id=5059f8619189a5000201fbcb

<In what way does your code behave incorrectly? Include ALL error messages.>

```

movie_ratings.each_key { |k| puts k, " " }
movie_ratings.each_key { |k| puts "#{k} " }

<do not remove the three backticks above>

puts k, " " and puts "#{k} " have different outputs. First one will print k variable, then in a new line it will print " " which is just another empty line. Second one will print variable k in a line.
If you want same effects, either choose between puts k and puts "#{k}"
Or if you really want that " " - space which is pointless in case of using puts - puts k.to_s + " " and puts "#{k} "

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.