# Simple replacement str.replace(old, new, count) # Multi-match replacement import re STRING = re.sub("(\.fasta|\.fna)","", STRING)
#our text text='Hello! there/ how may. I help, you' #yes, it seems weird #replacing ("THIS" with "THIS") replaced_text=text.replace("!", "?") print(replaced_text) #output #Hello? there/ how may. I help, you
# Replace 1 with 4 s = {1, 2, 3} s.remove(1) s.add(4)