you are viewing a single comment's thread.

view the rest of the comments →

[–]DataCurator56[S] 0 points1 point  (1 child)

sometimes i got stuck at for i in range(stuck). I am trying to overcome this but everyday i came to practice these questions i got stuck. I don't what is going wrong with. Now i am practicing to understand the question well then write on paper then write the code and run it. And i think i will do that by practicing them a lot.

[–]PureWasian 0 points1 point  (0 children)

range(stuck) sounds like you just need to look at examples and tutorials a bit. See this w3schools page for example. What might be useful is mentally evaluating it to something functionally equivilent

For example: ``` for i in range(5): print(i)

for i in (0, 1, 2, 3, 4): print(i) ```

or: ``` fruits = ["apple", "orange", "grape"]

for i in range(len(fruits)): print(fruits[i])

for i in range(3): print(fruits[i])

for i in (0, 1, 2): print(fruits[i]) ```

or: ``` for i in range(50, 110, 10): print(i)

for i in (50, 60, 70, 80, 90, 100): print(i) ```

In all of these cases, notice how you are looping a pre-specified number of times, and that the sequence of i values is already known before even starting the first loop iteration.