May-23-2018, 06:37 PM
Your idea is good. The thing you have to consider is that when you say
so simply change your code to:
The second error was due to you trying to call the list like a function list_mounts(x, y), but it is an Object of List and not a function, therefore you get the "object not callable" error.
The third error was due to the fact that you called a list with [x, y] x and y are interpreted as a tuple and that cannot be applied to lists, but it can to arrays ;) since it needs an integer it throws the "indices must be integers or slices, not tuple" error.
for i in list_mountsyou are picking each line at once out of the list. If you would say:
for x, y in list_mountsyou are picking each line and save the elements of the gotten line to x and y
so simply change your code to:
for x,y in list_mounts: print("Drive: ", x, "Used Space: ", y)x and y are your values contained in the nested lists so that y becomes an integer so that you can not iterate over this (that was the first error.
The second error was due to you trying to call the list like a function list_mounts(x, y), but it is an Object of List and not a function, therefore you get the "object not callable" error.
The third error was due to the fact that you called a list with [x, y] x and y are interpreted as a tuple and that cannot be applied to lists, but it can to arrays ;) since it needs an integer it throws the "indices must be integers or slices, not tuple" error.