Build a Number Pattern Generator - Build a Number Pattern Generator

Tell us what’s happening:

Kindly someone help. My steps 3,4, 5 are not going through.

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.'
    else:
        number = ''
        for i in range(1,n+1):
            number += str(i)+' '
    return number

number_pattern(4)

Your browser information:

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

Challenge Information:

Build a Number Pattern Generator - Build a Number Pattern Generator

consider what happens the last time this run

you add a space at the end of the string, nothing will come after it

is that the intended output? should it have a space at the end?

I used both the rstrip abd rstrip metods to remove traiing and leading spaces. Steps 3, 4 and 5 are not still going through

def number_pattern(n):

    if not isinstance(n, int):

        return 'Argument must be an integer value.'

    elif n < 1:

        return 'Argument must be an integer greater than 0.'

    else:

        number = ''

        for i in range(1,n+1):

            number += str(i)+' '

            number.strip(')

    return number



number_pattern(4)

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Do you have an error message in the terminal?

You should print your function call so you can see what your function is returning. How can you test it otherwise?

this is not correct syntax, you have started a string adn not closed

also consider what strip does, does it change the string it is used on, or does it create a new string?