Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.29 KB | None | 0 0
  1.  
  2. print "Please enter a word: "
  3. word = gets.chomp
  4. is_palindrome = true
  5. (0..word.length/2).each do |x|
  6.   if word[x] != word[-(x+1)]
  7.     is_palindrome = false
  8.     break
  9.   end
  10. end
  11.  
  12. if is_palindrome
  13.   puts "\"#{word}\" is a palindrome"
  14. else
  15.   puts "\"#{word}\" is not a palindrome"
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement