title: Print multiple variables in one line using python
body: <p>I need some assistance with a python script. I need to search a dhcpd file for host entires, their MAC and IP, and print it in one line. I am able to locate the hostname and IP address but cannot figure out how to get the variables out of the if statement to put in one line. Any suggestions, the code is below:</p>
  
  <pre><code>#!/usr/bin/python
  
  import sys
  import re
  
  #check for arguments
  
  if len(sys.argv) &gt; 1:
      print "usage: no arguments required"
      sys.exit()
  else:
      dhcp_file = open("/etc/dhcp/dhcpd.conf","r")
      for line in dhcp_file:
          if re.search(r'\bhost\b',line):
              split = re.split(r'\s+', line)
              print split[1]
          if re.search(r'\bhardware ethernet\b',line):
              ip = re.split(r'\s+',line)
              print ip[2]
      dhcp_file.close()
  </code></pre>