Iterate over a Go string using a for loop with range to access indices and runes.
Use a for loop with the range keyword to iterate over a string, which yields the index and the rune at each position.
s := "hello"
for i, r := range s {
fmt.Printf("Index: %d, Rune: %c\n", i, r)
}
If you only need the runes and not the indices, use _ to discard the index variable.
The range keyword lets you loop through every character in a string one by one. It automatically gives you the position (index) and the character itself (rune) at each step. Think of it like reading a book line by line while keeping track of the page number.