I think it is more appropriate to write Solution 2 as:print(n) if n % 10 == 0 else print(10*n)instead of:print(n) if n % 10 == 0 else 10*n
if num%2 == 0: ...: print('even') ...: else: ...: print('odd') File "<ipython-input-2-1f320c4e94c2>", line 3 else: ^SyntaxError: invalid syntax
14478 visits
Outline:if condition statement Demonstration of if statement with example if/else condition statement with example Importance of indentation in a program Usage of colon in program Condition statement using elif Examples using if/elif/else block Ternary conditional statement Difference between if/else and ternary conditional statements How to use pass statement?
if condition statement Demonstration of if statement with example if/else condition statement with example Importance of indentation in a program Usage of colon in program Condition statement using elif Examples using if/elif/else block Ternary conditional statement Difference between if/else and ternary conditional statements How to use pass statement?
Show video info
Pre-requisite