new file go/l9.go for counting the word go
This commit is contained in:
parent
7a82960a38
commit
574fdaaaea
2 changed files with 28 additions and 8 deletions
20
go/l9.go
Normal file
20
go/l9.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Введите фразу")
|
||||
var pol string
|
||||
fmt.Scanln(&pol)
|
||||
poll := strings.ToLower(pol)
|
||||
if strings.Contains(poll, "go") {
|
||||
x := strings.Count(poll, "go")
|
||||
fmt.Println(x)
|
||||
} else {
|
||||
x2 := poll + " go"
|
||||
fmt.Println(x2)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue