+ 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
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:])
+ 3
Russ nailed it (I misunderstood the question 😜)
+ 2
for i in range(9, 0 , -1):
a = [j for j in range(i, 0, -1)]
print(*a)
+ 1
thank you both of you😊