Section11-2

This commit is contained in:
2023-11-15 15:18:17 +01:00
parent 110aab4934
commit 12c600ef09
3 changed files with 83 additions and 0 deletions

21
Section11/89-1.go Normal file
View File

@@ -0,0 +1,21 @@
/*
Coding Exercise #1
Using a composite literal declare and initialize
a slice of type string with 3 elements.
Iterate over the slice and print each element in
the slice and its index.
*/
package main
import "fmt"
func main() {
countries := []string{"Romania", "Brazil", "Germany"}
for i, v := range countries {
fmt.Printf("Index: %d, Element: %q\n", i, v)
}
}