How to access the low digits of a list
Steven D'Aprano
steve at pearwood.info
Tue Jun 2 11:11:27 EDT 2015
On Tue, 2 Jun 2015 10:23 pm, fl wrote:
> I don't know whether there is a way to know the length of lines[3].
The same way as to know the length of anything else:
len(x) # the length of x
len("hello") # the length of "hello"
len(lines[3]) # the length of lines[3]
> Then,
> I can use a -1 step to get the last two digits. Or, you may have much
> better ways to do that. Python is really too versatile I feel.
Last two digits of a string:
mystring = "123456"
mystring[-2:]
--
Steven
More information about the Python-list
mailing list