Module 4

Negative indexing

Counting from the end.

From the end

Python lets you count from the end of a string using negative indices. -1 is the last character, -2 is the second to last, and so on.

Python
seq = "ATGC"
print(seq[-1])
print(seq[-2])
C G
Your task

Negative index

  • Store ATGC and print the last character using a negative index.