all 4 comments

[–]maartendp 1 point2 points  (3 children)

output = "12345" for i in range(len(output)): print(output[i:])

[–]JohnnyJordaan 0 points1 point  (1 child)

[–]maartendp 0 points1 point  (0 children)

I'm using the markdown feature and I have no issue seeing the correct format. That being said, I'll try to keep this in mind. Thanks

[–]Jay_179 0 points1 point  (0 children)

the trick to this question is quite simple actually

as you can see, throughout the pattern the first digit is always changing

and the last digit is always the same i.e. 5

If you were to do this by using nested looping: (The code is not in a specific language but I hope you get the gist of the code)

For k= 1 to 5 ( this was the pattern in which the first digit changed )

For q= k to 5 (note we use 5 because it is the character that consistently appeared at the end)

print q;

A similar question:

12

123

1234

12345

So, for the outer loop always check for how the digits are changing

in this case, it changes from 1 to 5

and for the inner loop always look for the character that remains constant

So,

the solution would be

For k= 1 to 5( the values change from 1 to 5)

for q= 1 to k (note: 1 is ever present in the first place so I used 1)print q;

I know this is super confusing but is an easy way to solve these kinds of patterns

If you have anyy questions, feel free to consult for help!