i want to display this number pattern in python, help me!

9
89
789
6789
56789
456789
3456789
23456789
123456789

I was able to write this in one line. Here it is.

print "9\n89\n789\n6789\n56789\n456789\n3456789\n23456789\n123456789\n"

In case this doesn't fit your top post's requirement, I would be guessing if more was required.
If I'm wrong, read https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question first.

commented: Brilliant, efficient and succinct. 10/10 +9
commented: Great! +15

Python has a nice thing called sequence slicing:
[starting-at-index : but-less-than-index [ : step]]
'start' defaults to 0, 'end' to len(sequence), 'step' to 1

for instance
s = "123456789"
then
s[-1:] --> 9
s[-2:] --> 89
s[-3:] --> 789
and so on,
do this with a for loop in range(1, 10)

s = "123456789"

for k in range(1, 10):
    print(s[-k:])

''' output...
9
89
789
6789
56789
456789
3456789
23456789
123456789
'''

@vegaseat - As a long standing member you should know better than to reward lazy/bad behaviour.

You are so right, I thought since 2 month had gone since the original request the whole thing became a teaser for the mind.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.