Created
          April 23, 2022 17:12 
        
      - 
      
- 
        Save TheBraveByte/6f46b0b2c68bd8c55ab31ed85441e590 to your computer and use it in GitHub Desktop. 
Revisions
- 
        TheBraveByte created this gist Apr 23, 2022 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ import ( "bufio" "fmt" "io" "os" "strings" ) func ReadLine(reader *bufio.Reader) string { str, _, err := reader.ReadLine() if err == io.EOF { return "" } return strings.TrimRight(string(str), "\r\n") } func EvenOddIndex() { fmt.Println("Enter a string value (2<= string <=10000) : ") reader := bufio.NewReader(os.Stdin) str := strings.TrimSpace(ReadLine(reader)) switch { case len(str) == 1: fmt.Print() break case len(str) > 1: evenIndex := "" oddIndex := "" for i, v := range str { if i%2 == 0 || i == 0 { evenIndex = evenIndex + string(v) } else if i%2 >= 1 { oddIndex = oddIndex + string(v) } } //fmt.Println("The characters in even index : ", evenIndex) //fmt.Println("The characters in odd index : ", oddIndex) fmt.Println(evenIndex, oddIndex) break default: fmt.Println("Input value less than 1") } }