I'm having a problem which I had for ages without finding a solution.
The code is this:
Df = range(100)
function = '3*x+4'
for i in Df:
listoffunction = list(function) #Will return ['3', '*', ...]
for obj in listoffunction:
if obj == 'x' :
obj = i
resultfori = ''
for part in listoffunction:
resultfori.join(part) #until here everything is fine.
#resultfori is the following: '3*i+4'
#with i the number of Df
Here is my problem: How can I calculate this term? I've tried it with the exec
command but it always returns None
. Why? I want it for example if i is 3 to return 13. Can you help me?
Thanks a lot!