What is the Python equivalent of JavaScript's charAt() method?
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:
Syntax
string[index]
Parameters
The index is an integer indicating the position from where the character has to be extracted.
Code
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)