Build a Number Pattern Generator - Build a Number Pattern Generator

Tell us what’s happening:

What’s wrong with this code? please help to resolve.

Your code so far

def number_pattern(n):
    if not isinstance(n,int):
        print("Argument must be an integer value.")
    if n<1:
        print("Argument must be an integer greater than 0.")
    str_num=''
    for i in range(1,n+1):
        #return(" ".join(str(i)))
        #print(i,end = ' ')
        str_num+= str(i)+' '
    return(str_num)
a=number_pattern(0)
print(a)
        
    

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Mobile Safari/537.36

Challenge Information:

Build a Number Pattern Generator - Build a Number Pattern Generator

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-number-pattern-generator/6842a6cd9836f0114a5b7a8a.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @ArtiGautam84,

Are you asked to print the validation messages or return them?

And while the digits in your string should be separated by a space, should the string end with a space?

Check it like this:

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

Happy coding