I have a string as follows:
f = 'ATCTGTCGTYCACGT'
I want to check whether the string contains any characters except: A, C, G or T, and if so, print them.
for i in f:
if i != 'A' and i != 'C' and i != 'G' and i != 'T':
print(i)
Is there a way to achieve this without looping through the string?
forloop, or any looping construct. For example, under the hood, functional programming methods (any,map), and it could be argued thatregexdoes as well. For clarity do you want to avoid any function that employs a looping construct, or avoid the basic looping functions, such asfor,while, etc ? If the former, perhapsset, for the latter, I'd probably take a regex (match) approach.