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
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.