fb pixel

string modifying methods

Method
Description
Examples
Results
replace('a', 'b')
Replaces all the occurrences of a with b
'Abcde'.replace('A', 'B') 'ABBA'.replace('A', 'B') 'ABBA'.replace('AB', 'C')
Bbcde BBBB CBA
strip()
Removes whitespace from both ends
' Hi Bob '.strip()
Hi Bob
lstrip()
Removes whitespace from the beginning
' Hi Bob '.lstrip()
Hi Bob
rstrip()
Removes whitespace from the end
' Hi Bob '.rstrip()
Hi Bob
removeprefix('a')
Removes the specified prefix if it’s present
'Hi Bob!'.removeprefix('Hi') 'Hi Bob!'.removeprefix('hi')
Bob! Hi Bob!
removesuffix('a')
Removes the specified suffix if it’s present
'Hi Bob!'.removesuffix('!') 'Hi Bob?'.removesuffix('!')
Hi Bob Hi Bob?
The methods replace and strip are very popular and are used pretty often in real-life programs.

Challenge

Each gene's code uses the four nucleotide bases of DNA: adenine (A), cytosine (C), guanine (G), and thymine (T). We don’t like abbreviations, so we would like to expand these abstractions any time we find those in the text. Given a text with abstractions including A, C, G, and T, expand those into their actual names.
The input contains a single line with text with abbreviations.
The program should print the same text with expanded abstractions in the output.
Input
Output
Each gene's code uses the four nucleotide bases of dna: A, C, G, and T
Each gene's code uses the four nucleotide bases of dna: adenine, cytosine, guanine, and thymine
 
To check your solution you need to sign in
Sign in to continue