import subprocess

def get_uptime():
    """ Return the uptime of the system as a str using the command: $ uptime
    """
    proc = subprocess.Popen(["uptime"], stdout=subprocess.PIPE, shell=True)
    (output, error) = proc.communicate()
    uptime = output.decode("utf-8").split()[2]
    uptime = uptime[0:len(uptime)-2] # remove the comma
    return uptime

import subprocess

def get_uptime():
    """ Return the uptime of the system as a str using the command: $ uptime
    """
    proc = subprocess.Popen(["uptime"], stdout=subprocess.PIPE, shell=True)
    (output, error) = proc.communicate()
    uptime = output.decode("utf-8").split(",")[0]
    uptime = uptime[uptime.find("up")+3:len(uptime)] # extract uptime
    return uptime

Correct get_uptime function. It didn't extract the uptime correctly. Now it does.
Correct get_uptime function. It didn't extract the uptime correctly. Now it does.

  import subprocess
  
  def get_uptime():
      """ Return the uptime of the system as a str using the command: $ uptime
      """
      proc = subprocess.Popen(["uptime"], stdout=subprocess.PIPE, shell=True)
      (output, error) = proc.communicate()
-     uptime = output.decode("utf-8").split()[2]
+     uptime = output.decode("utf-8").split(",")[0]
-     uptime = uptime[0:len(uptime)-2] # remove the comma
+     uptime = uptime[uptime.find("up")+3:len(uptime)] # extract uptime
      return uptime
  
Correct get_uptime function. It didn't extract the uptime correctly. Now it does.
## Code Before:
import subprocess

def get_uptime():
    """ Return the uptime of the system as a str using the command: $ uptime
    """
    proc = subprocess.Popen(["uptime"], stdout=subprocess.PIPE, shell=True)
    (output, error) = proc.communicate()
    uptime = output.decode("utf-8").split()[2]
    uptime = uptime[0:len(uptime)-2] # remove the comma
    return uptime

## Instruction:
Correct get_uptime function. It didn't extract the uptime correctly. Now it does.
## Code After:
import subprocess

def get_uptime():
    """ Return the uptime of the system as a str using the command: $ uptime
    """
    proc = subprocess.Popen(["uptime"], stdout=subprocess.PIPE, shell=True)
    (output, error) = proc.communicate()
    uptime = output.decode("utf-8").split(",")[0]
    uptime = uptime[uptime.find("up")+3:len(uptime)] # extract uptime
    return uptime
