Feb-28-2023, 10:55 PM
Sounds like a homework assignment.
The trick is that /proc/partitions uses whitespace to look somewhat like a table. You cannot use split(' ') because that would give you something like this (based on running this code on my PC):
The trick is that /proc/partitions uses whitespace to look somewhat like a table. You cannot use split(' ') because that would give you something like this (based on running this code on my PC):
Output:['8', '', '', '', '', '', '', '', '0', '', '', '39080664', 'sda']
['8', '', '', '', '', '', '', '', '1', '', '', '', '', '524288', 'sda1']
['8', '', '', '', '', '', '', '', '2', '', '', '38555335', 'sda2']
So you either need to remove the extra whitespace or find a way to treat multiple blanks as one. I think I remember there being a re.split() where you can specify a regex pattern. I would start looking there.