Python does have a ternary operator, like Lua and many other languages
But unlike Lua, Python does not handle an undefined variable as a "false" value, it will throw an error if you attempt to evaluate an undefined variable. Specifically in your case you will get a key error for the key ticker not being present.
Lua Ternary:
total_volume[ticker] = (total_volume[ticker] or 0) + a
Python Equivalent:
total_volume[ticker] = (total_volume[ticker] if ticker in total_volume else 0) + a
Where Lua will pass you the value before the or if it is truthy, python will pass you the value before the if when the statement that follows is true, and the value after the else when it is false.
To safely evaluate if the key was in the dictionary we can use in.
This is mostly to demonstrate the ternary operation you were using in Lua and how to do it in Python, but that doesn't mean it is the right tool for this problem.
A cleaner solution I would suggest:
total_volume[ticker] = total_volume.get(ticker, 0) + 1
It is less code and easier to reason about. get will return total_volume[ticker] or if the key is not present in the dictionary it will return the default value, 0.
a = (None or 0) + 1would do what you want, but I cannot see a use-case.a=0?