Code Snippet: Access Individual Characters

From Coder Merlin™

Swift

let s = "Alpha:Bravo:Charlie:Delta" 
let a = Array(s)                                                                                                                                                                                         
print("The fourth character is: \(a[3])")

Java

String s = "Alpha:Bravo:Charlie:Delta";
System.out.println("The fourth character is " + s.charAt(3));

Python

s = "Alpha:Bravo:Charlie:Delta" 
print("The fourth character is: " + s[3])