Sobes.tech
Junior — Middle

Can a loop be used to iterate over the characters of a string?

sobes.tech AI

Answer from AI

Yes, in Swift you can use a loop to iterate over the characters of a string. A string in Swift is a collection of characters, so you can use a for-in loop to access each character sequentially.

Example:

let text = "Hello"
for character in text {
    print(character)
}

This code will print each character of the string on a new line.

Can a loop be used to iterate over the characters of… - sobes.tech