Pavan Nath Pavan Nath - 4 years ago 120
Python Question

why sort in python is not working?

print (list)

Actual output:
['1', '432', '549834', '85863', '93']
#why sort is not working
Expected output:

I have tried other sort operations also but they are displaying same output.
when i tried to read list from keyboard input they are reading only strings but not int please help me why?

Answer Source

You need to first convert the strings to int.

list = [int(ele) for ele in list]
print list
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download