Python:Control structures
Jump to navigation
Jump to search
Most flow control is standard. Indentation defines the code block to execute. You must be strich, all indents must be the same in a block, amix of spaces and tab is not allowed (unless each line uses the same mix)..........
if expression:
block
else:
otherblock
pass
- No operation, use e.g. to avoid negative tests
Exception handling
To catch all exceptions (not wise)
try:
block
except:
blockifexceptionisthrown
You better only catch the exceptions you expect. You can choose from the available exceptions [1]
- except NameError
- The variable does not exist