forked from MJK618/100HoursOfGo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhour6.go
More file actions
39 lines (31 loc) · 684 Bytes
/
Copy pathhour6.go
File metadata and controls
39 lines (31 loc) · 684 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
39
package _100HoursOfGo
import (
"bufio"
"fmt"
"os"
)
func hour6() {
//Working with maps and Dictionaries
var mymap map[string]int
mymap = make(map[string]int)
mymap["India"] = 138
mymap["China"] = 150
mymap["Nepal"] = 10
for key := range mymap {
fmt.Println(key, " = ", mymap[key])
}
//Using Buffio and other modules for inputs and outputs
fmt.Println("Enter a string")
scn := bufio.NewReader(os.Stdin)
str, err := scn.ReadString('\n')
if err == nil {
fmt.Println(len(str))
str = str[:len(str)-2]
fmt.Println(len(str))
for i := 0; i < len(str); i++ {
for j := i + 1; j <= len(str); j++ {
fmt.Println("(", i, "-", j, ")", str[i:j])
}
}
}
}