mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nprimo
e3251487b7
|
5 months ago | |
---|---|---|
.. | ||
README.md | 5 months ago | |
main.go | 5 months ago |
README.md
lastword
Instructions
Write a function LastWord that takes a
stringand returns its last word followed by a
\n`.
- A word is a section of
string
delimited by spaces or by the start/end of thestring
.
Expected function
func LastWord(s string) string{
}
Usage
Here is a possible program to test your function :
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Print(piscine.LastWord("this ... is sparta, then again, maybe not"))
fmt.Print(piscine.LastWord(" lorem,ipsum "))
fmt.Print(piscine.LastWord(" "))
}
And its output :
$ go run . | cat -e
not$
lorem,ipsum$
$
$