short hend if_else not working with assignment operater

20 Views Asked by At

When i try short hend if_else stetment with assingment operater syntaxerror is happening.i want to result based on the condition.like if condition is true so print 1 otherwise 0.

a=100
b=20
c=1 if(a>b) else c=0
print(c)

expecting 1 or 0 based on the condition.

1

There are 1 best solutions below

1
yukii On BEST ANSWER

try

a=100
b=20
c=1 if(a>b) else 0
print(c)

you do not have to redeclare that c = 0 after the else, if i am correct.