Answers for "python split last two characters of string"

11

how to select last 2 elements in a string python

>>>mystr = "abcdefghijkl"
>>>mystr[-4:]
'ijkl'

>>>mystr[:-4] #to select all but last 4 characters
'abcdefgh'
Posted by: Guest on July-09-2020
0

python split only last occurrence of a character

s.rsplit(',', 1)
s.rpartition(',')
Posted by: Guest on May-18-2020

Code answers related to "python split last two characters of string"

Python Answers by Framework

Browse Popular Code Answers by Language