In JavaScript, the charAt()
method takes a character out of a string from a particular index. Similarly, Python also has an equivalent in it, and its syntax is as follows:
string[index]
The index
is an integer indicating the position from where the character has to be extracted.
In the code below, x
returns the character which is present at the string’s eighth index:
# extracting eighth character of the stringstring = "Welcome to Educative"index = 8x = string[index]print ("The character at index",index,"is",x)