how to use sum with range python

res = sum(x for x in range(100, 2001) if x % 3 == 0)

Here is what the above code is Doing:
1. We create a list comprehension that iterates over the range of numbers from 100 to 2001.
2. We check if the number is divisible by 3.
3. If the number is divisible by 3, we add it to the list.
4. We then sum up all the numbers in the list.