python django how to remove last element from a list or string.
python django how to get all elements except last one.
>>> a = range(6)
>>> a
[0, 1, 2, 3, 4, 5]
>>> a[0:-1] <----- get all elements, except 5
[0, 1, 2, 3, 4]
---------------------------
>>> name = "python&"
>>> name
'python&'
>>> name[:-1] <----- get all elements, except &
'python'
===============================
No comments:
Post a Comment