+ 1

I have to get a pattern printed in this manner

9 8 4 6 5 7 3 2 1 8 4 6 5 7 3 2 1 4 6 5 7 3 2 1 6 5 7 3 2 1 5 7 3 2 1 7 3 2 1 3 2 1 2 1 1 I have to swap 4 and 7... Thank You in advance

16th Jun 2018, 5:49 AM
Amrish Mishra
Amrish Mishra - avatar
4 Antworten
+ 3
a = [i for i in range(9,0,-1)] b = a.index(4) c = a.index(7) a[b], a[c] = a[c], a[b] for i in range(len(a)): print(*a[i:])
16th Jun 2018, 9:36 AM
Russ
Russ - avatar
+ 3
Russ nailed it (I misunderstood the question 😜)
16th Jun 2018, 12:16 PM
David Ashton
David Ashton - avatar
+ 2
for i in range(9, 0 , -1): a = [j for j in range(i, 0, -1)] print(*a)
16th Jun 2018, 8:50 AM
David Ashton
David Ashton - avatar
+ 1
thank you both of you😊
18th Jun 2018, 5:40 AM
Amrish Mishra
Amrish Mishra - avatar