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 string
string = "Welcome to Educative"
index = 8
x = string[index]
print ("The character at index",index,"is",x)
New on Educative
Learn any Language for FREE all September 🎉,
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources