Python Forum

Full Version: How to call/read function for all elements in my list in python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everybody,

i need help with a code i have written.

i have defined a function to compare two sequences with the def statement. Now i want to read the code of def function for all strings in my list, but i want to compare all strings.

it looks like that:

new_sequ=['XYZ','ZXY'...] example of list

def sequ(s1,s2):

..............
..............
sequ((new_sequ[0]),(new_sequ[1])) --> i call the function for the 0th and 1st of my list.

therefore i want to read the function for all strings in my list. I want to compare 0th with 1st.. 0th with 2nd ..0th with 3th.... and so on .... then 1st with 2nd....1st with 3rd element....and so on. 2nd with 3th ...2nd with 4th element.... like this.

I hope i described it good enough.
look at itertools.product