title: Handling an empty string - Python
body: <p>I have to do a program for a Hexidecimal to Binary converter. I have it working fine. However the only thing that doesn't quite go to plan is if an empty string is entered. If invalid data is entered it produces an error, apart from when nothing is entered, where nothing is produced either. No error comes up, but it doesn't do anything either.</p>
  
  <p>How would I make the error come up for an empty string?</p>
  
  <pre><code>def Binary(Hex):
      Result = ''
      ErrorFound = False
      BinaryEquivalent = ''
      for ThisHexDigit in Hex:
          if ThisHexDigit in ['1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F']:
              if ThisHexDigit == '0': BinaryEquivalent = '0'
              elif ThisHexDigit == '1': BinaryEquivalent = '1'
              elif ThisHexDigit == '2': BinaryEquivalent = '2'
              elif ThisHexDigit == '3': BinaryEquivalent = '3'
              elif ThisHexDigit == '4': BinaryEquivalent = '4'
              elif ThisHexDigit == '5': BinaryEquivalent = '5'
              elif ThisHexDigit == '6': BinaryEquivalent = '6'
              elif ThisHexDigit == '7': BinaryEquivalent = '7'
              elif ThisHexDigit == '8': BinaryEquivalent = '8'
              elif ThisHexDigit == '9': BinaryEquivalent = '9'
              elif ThisHexDigit == 'A': BinaryEquivalent = '10'
              elif ThisHexDigit == 'B': BinaryEquivalent = '11'
              elif ThisHexDigit == 'C': BinaryEquivalent = '12'
              elif ThisHexDigit == 'D': BinaryEquivalent = '13'
              elif ThisHexDigit == 'E': BinaryEquivalent = '14'
              elif ThisHexDigit == 'F': BinaryEquivalent = '15'
              Result = Result + BinaryEquivalent
          else:
              ErrorFound = True
              print('You have made a mistake')
      return Result
  </code></pre>