If "nl10301" is a list, you can use the min
and max
functions to find the minimum and maximum values in the list, respectively:
main.py72 chars4 lines
If "nl10301" is actually a string that represents a list of numbers, you can convert it to a list using the eval
function and then apply the min
and max
functions:
main.py106 chars5 lines
Note that using eval
can be unsafe if you are parsing untrusted input, as it can execute arbitrary code. In that case, you should consider using a safer alternative like the ast.literal_eval
function.
gistlibby LogSnag