+ 3

Challenge: How to print the last second indexed value in one line of code without using length function.....?

ex: arr = [1,4,5,80,8,2] output : 8

15th Dec 2017, 6:55 PM
Janagama Prabhakar
Janagama Prabhakar - avatar
5 odpowiedzi
+ 3
print(arr[::-2] )
15th Dec 2017, 8:31 PM
Oma Falk
Oma Falk - avatar
+ 3
print(arr[-2])
16th Dec 2017, 1:33 AM
Amir Galanty
Amir Galanty - avatar
+ 2
@Oma Falk, take a look at the code I attached what's the difference. https://code.sololearn.com/cAU9Z32Jp47c/?ref=app
16th Dec 2017, 1:38 AM
Amir Galanty
Amir Galanty - avatar
+ 2
https://code.sololearn.com/cBk4IbXVkE49/?ref=app
22nd Dec 2017, 5:47 PM
...
+ 1
nice
16th Dec 2017, 2:35 AM
Janagama Prabhakar
Janagama Prabhakar - avatar