Answers for "get the last 3 elements of a str python"

15

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
1

python print last 3

message = iloveyouchina
#get last x words
#for example x = 3
print(message[-3:]
Posted by: Guest on July-09-2020

Code answers related to "get the last 3 elements of a str python"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language