import Foundation
let s = "Swift is a programming language for iOS, iPadOS, macOS"
let charToFind: Character = "O"
if let index = s.firstIndex(of: charToFind) {
let position = s.distance(from: s.startIndex, to: index)
print("The first occurrence of '\(charToFind)' is at index \(position)")
} else {
print("'\(charToFind)' not found in the string")
}
/*
run:
The first occurrence of 'O' is at index 37
*/