[Tutor] Problem solving

Alan Gauld alan.gauld at yahoo.co.uk
Sun Nov 15 18:28:59 EST 2020


On 15/11/2020 12:15, Robin Williamson via Tutor wrote:
> if b "or" v<r
>     print("rouge"):

The or should not be in quotes, it is not a string.

This should have triggered a n error message. When
you get an error always post it in full in the message,
they contain a lot of useful information.


Also the colon should be on the same line as the if
not after the print. The structure is:

if <test condition> <colon>
   <code to be executed if true>
<elif> <next test condition> <colon>
    <cofe to be executed if true>
else <colon>
   <code to be exceuted if false>

Where the elif section can be repeated and
both elif and else are optional. But notice
where the colons are positioned.


-- 
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