3 Antworten
+ 1
n=10 # N
odds = [x for x in range(1,n*2,2)]
print(odds)
=== output ===
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
+ 1
^ [::-1]
0
Markus Kaleton
Thanx, I've forgotten about the last condition. So the code will be :
>>> n=10
>>> odds = [x for x in range(1,n*2,2)]
>>> print(odds[::-1])
[19, 17, 15, 13, 11, 9, 7, 5, 3, 1]
>>>