- create partial sum of sequence using generator. ref: Blckknght’s answer
def partial_sums(iterable):
total = 0
for i in iterable:
total += i
yield total
- None and 0, ”, etc, as condition.
example, to solve two sum problem. below code
def twoSum(self, nums, target)