1

I am very new to programming. I've been watching youtube videos and reading anything I can get my hands.I have no formal training. admittedly this is not my code although I understand most of what it's doing I would like assistance understanding the error I am receiving. I have googled the error and read several posts on it. how ever the example are very basic and I don't know how to apply them to this code.

When I run the code below I receive the error: "Username2description-AD.py", line 81, in RAM_total = round(int(RAM_stats[0]) / 1000,1) IndexError: list index out of range "

def getRAMinfo():
p = os.popen('free')
i = 0
while 1:
    i = i + 1
    line = p.readline()
    if i==2:
        return(line.split()[1:4])




RAM_stats = getRAMinfo()
RAM_total = round(int(RAM_stats[0]) / 1000,1)
RAM_used = round(int(RAM_stats[1]) / 1000,1)
RAM_free = round(int(RAM_stats[2]) / 1000,1)

Thanks in advance for anyone that takes the time to assist.

Ben

0 Answers0