You can use the ternary operator to write multiple if-else statements in a single line. Here is the syntax to use the ternary operator:
[output on_true] if [expression] else [output on_false]
Here is the shortest python code to write an if statement:
ab= 'on' if c.page=='blog' else 'off'
To become an expert in Python, I recommend this Python Course by Intellipaat that provides instructor-led training, hands-on projects, and certification.