0
#nums=1324 # nums=nums(::-1) print(nums[2])
The answer is 3 I want to know how?
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""
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])