I am trying to get a list input by the user and then sort the list elements (which are integers) in ascending order. But the elements are stored as strings and I don't know how to convert each element into int
type. For example:
p = input("Enter comma separated numbers:")
p = p.split(",")
p.sort()
print(p)
When I input
-9,-3,-1,-100,-4
I get the result as:
['-1', '-100', '-3', '-4', '-9']
But the desired output is:
[-100, -9, -4, -3, -1]