Variable a doesn't exist
I can write in Lua language:
a = (a or 0) + 1
Now a = 1
this allows me not to declare the variable "a" in advance. This is analog of
a = 0
a = a + 1
How can I do the same in Python?
a = (a or 0) + 1
P.S. Why is it important? To avoid assign zero to variables:
python (4 lines of code):
for ticker in ticker_list:
total_volume[ticker] = 0
for a in range (1,10):
total_volume[ticker] = total_volume[ticker] + a
lua (2 lines of code):
for a=1,9 do:
total_volume[ticker] = (total_volume[ticker] or 0) + a