Q:

Write a Ruby program to get a substring from a specified position to the last char of a given string

0

Write a Ruby program to get a substring from a specified position to the last char of a given string.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def check_string(str, n)
   str = str[n...-1]
   return str
end
print check_string("JavaScript", 5)
print "\n",check_string("Python",3)
print "\n",check_string("Ruby", 2)
print "\n",check_string("PHP", 0)

Output:

crip
ho
b
PH

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now