From 1 to 100 → the digit 7 occurs 20 times. Count place by place:
In the tens place: 70, 71, 72, 73, 74, 75, 76, 77, 78, 79 → 10 times
Total = 10 + 10 = 20
Note that 77 is counted twice — and correctly so, because Dinesh writes the digit 7 twice while writing 77.
From 1 to 1000 → the digit 7 occurs 300 times.
That is 1000 numbers × 3 digit-places = 3000 digit-places.
Each of the ten digits 0–9 fills the same share: 3000 ÷ 10 = 300
(1000 itself has no 7, so it changes nothing.)