Traceback (most recent call last):
File "<string>", line 17, in <module>
print (convert_milliseconds(os.environ[mls]))
^^^
NameError: name 'mls' is not defined
Because you used single quotes within single quotes, they were skipped, and Python is trying to use a Python variable named mls, instead of the string literal 'mls'.
You could use double quotes, but you would get another problem, because environment variables are strings, so you would need to add a call to int(), like so:
Alternatively, you could embed the variable within the Python code. This won’t work very well if you’re dealing with strings, but with numbers, you can just do this:
$ mls=1000
$ python -c 'print(2 * '$mls')'
2000
Or you could pass data as arguments and read sys.argv: