title: ValueError: could not convert string to float: '' in Python 3
body: <p>I'm coding a little bot in Python and I'm having a problem. It seems to be a common problem, but I've never seen it asked in the same situation I'm in.</p>
  <p>Ok so here is the code posing problem:</p>
  <pre><code>old_values = float((removeprc(browser.find_element_by_xpath('//*[@id=&quot;draggableNavRightResizable&quot;]/section/section[2]/section[1]/div[3]/ul/li[1]/div[2]/div[6]/span').text)))
  </code></pre>
  <p><code>browser.find_element_by_xpath('//*[@id=&quot;draggableNavRightResizable&quot;]/section/section[2]/section[1]/div[3]/ul/li[1]/div[2]/div[6]/span').text)</code> is a selenium tool used to get a value of a website. as you will see later, the element retrieved is a number which should work with float()
  &quot;remove prc&quot; is a little function I created to remove the % of a number, here it is:</p>
  <pre><code>def removeprc(string): #removes the % from a string 
      string = str(string)
      list = string.split('%')
      string = &quot; &quot;.join(list)
      
      return string
  </code></pre>
  <p>It's probably not the best way to do it, but it works when I test it alone.</p>
  <p>anyway, here is what I get when I run my entire code</p>
  <pre><code>loading page ...
  page loaded
  acquiring values ...
  values acquired
  running eth trade
  -0.37
  Traceback (most recent call last):
    File &quot;C:\Users\pc adam\Documents\EISTI\algoprog\perso\python\fichiers\btc\ETHtradingbotV1.py&quot;, line 138, in &lt;module&gt;
      profit = float(browser.find_element_by_xpath('/html/body/div[3]/section[16]/section[2]/section[2]/section[2]/div/div[1]/table/tbody/tr/td[15]/span').text)
  ValueError: could not convert string to float: ''
  </code></pre>
  <p>the first 5 lines are useless. on the 6th line, I printed what i am trying to get the float()
  of. As you can see, it should work and ... It does ! sometimes.</p>
  <p>that's the weirdest thing about this, it works perfectly half the time!
  I've read on the internet that this can happen if you try to float() things that are not numbers or that have weird shit in them, like spaces. As you can see, I think it's not the case here.</p>
  <p>When I try to isolate the problem by running a simplified version of the program like this :</p>
  <pre><code>a = &quot;-0.06%&quot;
  def removeprc(string): #removes the % from a string 
      string = str(string)
      list = string.split('%')
      string = &quot; &quot;.join(list)
      return string
  
  b = float(removeprc(a))
  print(b)
  </code></pre>
  <p>it outputs -0.06 and works perfectly ???</p>
  <p>So I'm really stuck here. It should work, but it doesn't. Even worst, it works <em>sometimes</em>, for no reason. And when I isolate the problem, it works fine.</p>
  <p>Any help would be extremely appreciated!</p>
  <p>Oh and if you want to see the <em>entire</em> code, it's here: <a href="https://github.com/Madaxuorel/proj-ethTB/blob/master/ETHtradingbotV1.py" rel="nofollow noreferrer">https://github.com/Madaxuorel/proj-ethTB/blob/master/ETHtradingbotV1.py</a></p>