December 2000
Intermediate to advanced
816 pages
16h 57m
English
Like other languages, Python features an else statement that can be paired with an if statement. The else statement identifies a block of code to be executed if the conditional expression of the if statement resolves to a false Boolean value. The syntax is what you expect:
if expression: expr_true_suite else: expr_false_suite
Now the obligatory usage example:
if passwd == user.passwd: ret_str = "password accepted" id = user.id valid = 1 else: ret_str = "invalid password entered… try again!" valid = 0
Python's design of using indentation rather than braces for code block delimitation not only helps to enforce code correctness, but it even aids implicitly in avoiding potential problems in ...
Read now
Unlock full access