func solution(_ s:String) -> String {
    if s.count == 1 { return s }
    let Index1 = s.index(s.startIndex, offsetBy: s.count/2-1)
    let Index2 = s.index(s.startIndex, offsetBy: s.count/2)
    return s.count % 2 != 0 ? String(s[Index2]) : String(s[Index1...Index2])
}

 

 

ytw_developer