Write a Ruby program to remove the first and last two characters from a specified string

  • برمجة
  • برمجة روبي

 Write a Ruby program to remove the first and last two characters from a specified string.

الأجوبة

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

Output:

vaScri
th
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...