Question about my first Python loop printing 10 numbers when I asked for 5
Honestly I'm about 3 weeks into learning Python and last Tuesday I hit something that made me feel so dumb, in a good way. I was doing this practice problem where you print the first 5 even numbers, so I wrote a for loop with range(5) and inside it I printed i * 2. I hit run and got 0, 2, 4, 6, 8 which looked right, but then I tried changing it to range(1, 5) to skip the zero, and suddenly I got 2, 4, 6, 8 and only 4 numbers, so I sat there for like 40 minutes thinking my laptop was broken. I even restarted my editor twice and rewrote the whole file from scratch. Turned out range(1, 5) means start at 1 and end before 5, so it only runs 4 times, and I had been thinking about it totally wrong the whole time. What finally clicked was when I wrote out the numbers on paper and traced each pass by hand. Tbh I still catch myself assuming the end number is included, does anyone have a trick or a way you remember how range boundaries work when you start counting from somewhere other than zero?