Module 4

replace()

Replacing text within a string.

Changing text

The replace() method creates a new string where every occurrence of a substring is replaced with another.

Python
seq = "ATGC"
print(seq.replace("T", "U"))
AUGC
Biology connection

Replacing T with U is exactly how DNA becomes RNA. You just performed transcription.

Your task

Replace text

  • Replace T with U in ATGC.