I am learning python list comprehension and saw a usage and I couldn't find explanation in official document.
>>>[(not i%2)*'a' or str(i) for i in range(10)]
>>>['a', '1', 'a', '3', 'a', '5', 'a', '7', 'a', '9']
I am trying to abstract this usage in this way:
[statement1 or statement2 for i in range(10)]
and if statement1 is evaluated as false, then use statement 2, am I right?
I also discover that if I run the following command:
>>> [(not i%2)*'a' and str(i) for i in range(10)]
The output would be:
>>> ['0', '', '2', '', '4', '', '6', '', '8', '']
How should I understand these?