I am new to python. I have been coding a python calculator but floats are annoying because 0.1 + 0.2 != 0.3 so I have been using the decimal module. I have coded a script to convert the floats from the input to a decimal. I have first formatted the input string and then splitted it into a list. I run my script (for loop) on this list (called evalvar) but whenever I change the value of the i (iteration) to overwrite evalvar, nothing happens.
Code:
evalvar = ["0.1", "+0.2"]
for i in evalvar:
    try:
        #i is now equal to "0.1"
        i = str("""Decimal('""" + i + """')""")
        #i is now equal to """Decimal('0.1')"""
    except SyntaxError:
        print(evalvar)
I have worked out the answer myself.
Instead of using for i in evalvar I have used for i in range(len(evalvar)) and replaced all the i's in my for loop with evalvar[i].
 
    