0

#nums=1324 # nums=nums(::-1) print(nums[2])

The answer is 3 I want to know how?

21st Dec 2017, 11:35 AM
Vignesh R
Vignesh R - avatar
2 Answers
+ 6
#assign number nums=1324 #reverse the number digits nums=nums[::-1] # after reverse output nums=4231 #print 2 indexing digit of nums print(nums[2]) ""output =>3 so finally the output is 3""
21st Dec 2017, 11:54 AM
GAWEN STEASY
GAWEN STEASY - avatar
0
Please add a python tag to this post, at least. I guess it's from a challenge, but you copied it with a typo : there should be square brackets instead of parentheses around "::-1". Another way to get the same result : print ("1324"[::-1][2])
21st Dec 2017, 12:19 PM
Nonov Urbiznes
Nonov Urbiznes - avatar