if_true.md

April 17, 2022 ยท View on GitHub

If True

Improve the following block of code:

y = 0
x = False

if x == True:
    y = y + 1
if x == False:
    y = y + 2

Solution

x = False
if x:
    y = 1
else:
    y = 2