2021年4月2日星期五

Beginner Ruby Programmer- prints error on a practice problem

"Write a method reverse_range(min, max) that takes in two numbers min and max. The function should return an array containing all numbers from min to max in reverse order. The min and max should be excluded from the array"

print reverse_range(10, 17) puts print reverse_range(1, 7)

"its printing the wrong output, this is my ruby code"

def reverse_range(min, max)    nums = []      i = max - 1    while i > min      nums << i        i -= 1    end      return  end  
https://stackoverflow.com/questions/66927405/beginner-ruby-programmer-prints-error-on-a-practice-problem April 03, 2021 at 11:16AM

没有评论:

发表评论