Member Avatar

Do you know that there is clean way of doing what C-language ternary operator ? does in Python's recent versions. It is if with special twist. The syntax is: [CODE]'The value if true' if <condition> else 'Value when false'[/CODE] Values can be any type. You can put this structure to replace single value. In this classic number guess game version we practise using the structure even in a nested way. This is not maybe so advisable general way, as it is less clear than many print statements in normal if statement. Anyway, this came first to my mind as demonstration …

+0 forum 0

The End.