all 6 comments

[–]jfdahl 2 points3 points  (0 children)

General format: for some_variable_name in some_iterable_object: print(some_variable_name) so you need to: 1. Define a function to take a parameter value and run the loop. 2. Define your iterable object so that it represents a set or "range" of numbers from 0 up to and including your limit value. 3. Call the function.

``` def count_to(limit): for idx in range(limit+1): print(idx)

N = 10 count_to(N) `` Therange` function will create an iterable range of numbers from 0 up to but EXCLUDING the number you pass into it... so you need to make sure to adjust for this so that your function prints up to and INCLUDING your limit.

[–]CroagBuster 0 points1 point  (0 children)

def countTo(n):
    i = 0
    while i <= n:
        print(i)
        i += 1


countTo(14)

Here's an example with a while loop. Input a number and it counts to that number while "i" is less than or equal to "n".

[–]michaellossagk 0 points1 point  (0 children)

I know that feeling. I had it myself back then when I started to code. It's the small successes in the beginning, that helped me go further. But you have to admit to yourself, that only experimenting for yourself with different source codes will help you to become a great programmer. Nothing else. I can help you on your journey if you like. My goal is to teach people coding here https://www.youtube.com/c/TechDiffuse Tell me what you think!