How do I count the distance between strings in a list?

Ken Seehart ken at seehart.com
Sat Feb 28 01:06:26 EST 2009


collin wrote:
> For example, if I were to have the code
>
> randomlist = ["1", "2", "3", "4"]
>
> And I want to count the distance between strings "1" and "4" which is
> 3, what command can I use to do this?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>   
randomlist.index("4") - randomlist.index("1")

Ken




More information about the Python-list mailing list