Build a Number Pattern Generator - Build a Number Pattern Generator

Tell us what’s happening:

I’ve tried to find solutions without success…and since I’d also like to think about the errors to find a solution that will help me understand how to solve the exercise, I need help.

Your code so far

def number_pattern(n):

    if not isinstance(n, int):
        return 'Argument must be an integer value.'
    if n < 1:
        return 'Argument must be an integer greater than 0.'

    n=[]

    for n in range(0, 4):
        n = n+1 
        print(str(n))

    for n in range(0, 12):
        n = n+1
        print(str(n))

    return number_pattern



print(number_pattern(4))
print(number_pattern(12))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Number Pattern Generator - Build a Number Pattern Generator

Hi there,

Does it make sense to name an array variable and your loop variables the same as the function’s parameter.

It also looks like you have hard-coded conditionals or variables that check for specific expected values. That is not solving this problem in the general case. Imagine if you were given different input values. Would your code be able to solve those problems?

To find out more about what hard-coding is or about why it is not suitable for solving coding questions, please read this post: Hard-coding For Beginners

Let us know if you have a question about how to make your code more flexible.

Happy coding!


Yes, hardcoding isn’t a good solution. I should probably use more iterable variables. How could I make the code more flexible to solve the problem?

You can make your code more flexible by using the parameter passed to the function to create the range in your for loop.

ok, i have found the errors in my code and i fixed them….thank you so much

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.