def number_pattern(n):
numbers = ""
for number in range(1,n+1):
numbers += " " + str(number)
return (numbers)
print(number_pattern(12))
The step is not being fulfilled despite the output being the desired result. Is it because I did not use list comprehension.
ILM
2
can you please share your code formatted properly so it’s readable?
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 (').
def number_pattern(n):
numbers = ""
for number in range(1,n+1):
numbers += " " + str(number)
return (numbers)
print(number_pattern(12))
ILM
4
are you sure that is the correct indentation?
def number_pattern(n):
numbers = ""
for number in range(1,n+1):
numbers += " " + str(number)
return (numbers)
print(number_pattern(12))
ILM
6
consider if you could maybe have extra spaces?
There is a space before the 1 but I have no idea how to move it. Do I use “,” or “append’“
ILM
8
there are multiple ways to tackle this, figuring that out is part of the challenge
but pretty much you have two big families that can be summarisied to
- remove the extra space before returning
- do not add the extra space
def number_pattern(n):
numbers = ""
for number in range(1,n+1):
numbers += str(number)
numbers += " "
numbers = numbers.strip()
return (numbers)
print(number_pattern(12))
This seem like too much code for this to be a reasonable solution 
ILM
10
if it works it works, but you could use your previous code and only add strip on the return line, without adding extra lines
“If it works it works”
Me with my toaster on fire,but it’s still technically toasting my bread.
Thank you for the help.
ILM
12
no, do not consider something working if it’s going to format your computer, or make it overheat
something can be working even if it’s not the elegan solution you want, at this stage, working is fine, the second step is readable
golf code is not something to aim for (golf code is code that is as short as possible), it usually makes code not readable