Q. Modify your previous code so that SqLst stores the doubled numbers in ascending order.


Answer :-


NumLst = [2, 5, 1, 7, 3, 6, 8, 9]
SqLst = [ ]

for i in NumLst :
    SqLst .append( i * 2 )
SqLst.sort()
print (SqLst)


Output :-

[2, 4, 6, 10, 12, 14, 16, 18]
>>>

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post