I want to be able to bring in a lambda function from a txt file, and have it be able to run as if it were a normal section of code.
chain = "What has to be broken up"
reduction = 'lambda chain: chain[0:8]'
x = exec(reduction)
print(x) #only prints out 'None'
print(exec(x = reduction)) #causes error
print(exec(reduction)) #prints out 'None'
What I am hoping for the output to be is the first 8 characters of the string chain, 'What has'. How can I make this work to run the function?