Files
  • main.go
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main

import (
	"fmt"
	"strings"
)

func main() {

	var ip string
	fmt.Println("Enter string:")
	fmt.Scanf("%s\n", &ip)
	ip = strings.ToLower(ip)
	fmt.Println(isP(ip))
}

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"
}
go version go1.9.4 linux/amd64