[Tutor] GC content: Help with if/else statements:

Alan Gauld alan.gauld at btinternet.com
Mon Oct 14 12:41:36 EDT 2019


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



More information about the Tutor mailing list