Python Forum
How to call/read function for all elements in my list in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to call/read function for all elements in my list in python
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs


Possibly Related Threads…
Thread Author Replies Views Last Post
  Group List Elements according to the Input with the order of binary combination quest_ 10 166 51 minutes ago
Last Post: bowlofred
  Sorting Elements via parameters pointing to those elements. rpalmer 2 132 Jan-06-2021, 04:04 PM
Last Post: rpalmer
  In this function y initially has no value, but a call to foo() gives no error. Why? Pedroski55 8 336 Dec-19-2020, 07:30 AM
Last Post: ndc85430
  Adding List Element if Second part of the List Elements are the Same quest_ 3 217 Nov-25-2020, 04:33 PM
Last Post: bowlofred
  How to create a linked list and call it? loves 12 493 Nov-22-2020, 03:50 PM
Last Post: loves
  Struggling for the past hour to define function and call it back godlyredwall 2 266 Oct-29-2020, 02:45 PM
Last Post: deanhystad
  list call problem in generator function using iteration and recursive calls postta 1 201 Oct-24-2020, 09:33 PM
Last Post: bowlofred
  Remove specific elements from list with a pattern Xalagy 3 419 Oct-11-2020, 07:18 AM
Last Post: Xalagy
  function call at defined system time? Holon 5 441 Oct-06-2020, 03:58 PM
Last Post: snippsat
  Help accessing elements of list of dictionaries Milfredo 6 537 Sep-07-2020, 01:32 AM
Last Post: Milfredo

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020