In the code below when I inspect s[i]
it gives me binary numbers instead of characters. Code still works but how can I get s[i]
to return a character, while still using s type string as parameter?
func main() {
var ip string
fmt.Println("Enter string:")
fmt.Scanf("%s
", &ip)
ip = strings.ToLower(ip)
fmt.Println(isP(ip))
}
//Function to test if the string entered is a Palindrome
func isP(s string) string {
mid := len(s) / 2
last := len(s) - 1
for i := 0; i < mid; i++ {
if s[i] != s[last-i] {
return "NO. It's not a Palimdrome."
}
}
return "YES! You've entered a Palindrome"
}