I have some function FUN(a, b): on two characters. I want to define another function foo(s), such that
foo(s):
FUN(a[0],a[1])
FUN(a[2],a[3])
FUN(a[4],a[5])
...
for all characters in s (assume s is even length). My thoughts are that we basically need to run FUN(a,b) (len(s)%2) times, but I'm not sure how to iterate a function in that way, while also making sure FUN has the right inputs. Any ideas?
for i in range(0, len(s), 2): FUN(s[i], s[i+1])orfor i in range(0, len(s), 2): FUN(*s[i:i+2])