Hi, I’m have difficulty passing 2,3,4 on on here. I’m not quite sure where I’m going wrong? Thank you
Your code so far
def number_pattern(n):
if type(n) != int:
return("Argument must be an integer value.")
if n <= 0:
return("Argument must be an integer greater than 0.")
pattern = ""
for pattern in number_pattern:
pattern += range(1, n+1) + " "
x = strip.pattern()
return "x"
print(number_pattern)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 Edg/150.0.0.0
Challenge Information:
Build a Number Pattern Generator - Build a Number Pattern Generator
Your loop is attempting to iterate over the function name itself and append non-string range objects, while returning prematurely before completing the pattern. You should construct the string inside the loop using str(i), strip trailing whitespace after building the full sequence, and return the result instead of executing a print statement within the return block.
The i variable is iterating over an empty string, so the for loop does not run.
Photos/screenshots of an error can be helpful, but it also helps to provide the complete code. Posting the code helps us help you better!
When you enter a code, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.