How can I check if the letter "N" is present in a string. Example:
flag = False
if string contains N:
flag = True
So flag = True
if string is "CNDDDNTD"
and flag = False
if string is "CCGGTTT"
. I think re.search will work, but not sure of the options to use.
>>> 'N' in 'PYTHON'
True
>>> 'N' in 'STACK OVERFLOW'
False
>>> 'N' in 'python' # uppercase and lowercase are not equal
False
>>> 'N' in 'python'.upper()
True
Also, there is no need for a conditional statement when assigning to your flag
. Rather than
flag = False
if 'N' in your_string:
flag = True
do
flag = 'N' in your_string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With