What's correct Python syntax?

Jussi Piitulainen jpiitula at ling.helsinki.fi
Tue Jan 14 04:43:48 EST 2014


Chris Angelico writes:

> Alternatively, you can split on the space and take just the very
> last word:
> 
> for data in f:
>     length = data.split(" ")[-1]
>     # process length

Also, data.rsplit(' ', 1) will split data in two at the last space.

help(str.rsplit)



More information about the Python-list mailing list