add: numbers and strings exercises
This commit is contained in:
@ -0,0 +1,38 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE: Trim It
|
||||
//
|
||||
// 1. Look at the documentation of strings package
|
||||
// 2. Find a function that trims the spaces from
|
||||
// the given string
|
||||
// 3. Trim the text variable and print it
|
||||
//
|
||||
// EXPECTED OUTPUT
|
||||
// The weather looks good.
|
||||
// I should go and play.
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
msg := `
|
||||
|
||||
The weather looks good.
|
||||
I should go and play.
|
||||
|
||||
|
||||
|
||||
`
|
||||
|
||||
fmt.Println(msg)
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
msg := `
|
||||
|
||||
The weather looks good.
|
||||
I should go and play.
|
||||
|
||||
|
||||
|
||||
`
|
||||
|
||||
fmt.Println(strings.TrimSpace(msg))
|
||||
}
|
Reference in New Issue
Block a user