Why is this ternary operator syntax invalid?

Viewed 2186

I am trying to write a simple ternary operator which would look like this in ruby:

0 > 1 ? alice+=1 : bob+=1

I have it written in python like this:

alice += 1 if 0 > 1 else bob += 1

This ternary operator throws an invalid syntax at bob+=1. Why is this happening, and how can I make the second operator execute along the same lines as the first?

1 Answers
Related