I have a list of strings, and I want to call a function for every character in a string. When I assign variables to each function I do not want them to run, I only want to call them when iterating over the string. Here is my code:
import random
def make_s():
result = ''
V = make_v
C = make_c
P = make_p
B = make_b
structs = ['VPCVBCC', 'VCVVC', 'VVPCC', 'VCVBCC', 'VPCCVBC', 'VCVCC', 'VPCBC', \
'VVPCVBCC', 'VCVC', 'VPCVVBC']
struct = random.choice(structs)
for elem in struct:
/* Call function defined above and add the result to the result string */
result += elem()
return result
What's the best way to go about doing this?
Many thanks :)
dictinstead oflistmight be easier to implement