Learn Before
Code

Indexing examples

sentence = "Hello, 1Cademy! first_char = sentence[0] # python is zero-indexed last_char = sentence[-1] # a negative index counts from the back of the sequence, one-indexed print(sentence[4]) # prints 'o' print(sentence[-3]) # prints 'm'

0

2

Updated 2020-09-03

Tags

Python Programming Language

Data Science

Related