[Tutor] GC content: Help with if/else statements:
Mihir Kharate
kharatemihir at gmail.com
Sat Oct 26 12:32:55 EDT 2019
@Alan Gauld
Yes, I was quite confused. But I kept on working on my script and finally
figured the logic out and re-wrote my script like this:
def play_gc_count():
for character in input_sequence:
if character in ('A','T','G','C'):
x = True
for character in input_sequence:
if character not in ('A','T','G','C'):
x = False
while x is False:
w = print('Invalid Sequence')
break
w
while x is True:
z = gc_count()
break
z
play_gc_count()
Thanks for getting back tho! Appreciate it!
~Mihir
On Fri, Oct 25, 2019 at 7:58 PM Alan Gauld via Tutor <tutor at python.org>
wrote:
> On 13/10/2019 14:38, Alan Gauld via Tutor wrote:
>
> > Python doesn't see this the way you do.
> > It sees
> >
> > if (character == 'A') or
> > ('T' == true) or
> I should clarify that this is not actually what Python
> evaluates, it is only intended to illustrate the point.
> If you evaluate 'A'==True you will get False because
> the character 'A' does not actually equal the boolean
> value 'True', even though Python interprets it as
> true(note lower case!)...
>
> So what Python really sees is:
>
> if (character == 'A') or
> ('T') or ('G') or ('C'):
>
> Where it evaluates each character as a true boolean
> value (but not the actual boolean object "True").
>
> It just occurred to me after posting that I might have
> caused (more?) confusion with my "simplification"!
> Hopefully my explanation has helped rather than made
> it worse.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list