Invalid literal for int()
<p>I am learning python and I am trying to code a calculator that compares prices of butter, calculates percentage differences, and which one has the lowest price for 100 grams.</p>

<pre><code>def procenta(x,y):
 vysledek = (y-x)/x * 100            # (b-a) : a * 100
 return round(vysledek, 2)
tesco = float(input("Zadejte cenu masla v Tescu: "))
tesco_g = int(input("Zadejte gramaz v Tescu: "))
lidl = float(input("Zadejte cenu masla v Lidlu: "))
lidl_g = int(input("Zadejte gramaz v Lidlu: "))
kaufland = float(input("Zadejte cenu masla v Kauflandu: "))
kaufland_g = int(input("Zadejte gramaz v Kauflandu: "))

cena_tesco = int(tesco)/(tesco_g[:2]/10)
cena_lidl = int(lidl)/(lidl_g[:2]/10)
cena_kaufland = int(kaufland)/(kaufland_g[:2]/10)
</code></pre>

<p>Traceback:</p>

<pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
 File "python", line 6, in &lt;module&gt;
ValueError: invalid literal for int() with base 10: ''
</code></pre>

<p>DonÂ´t worry about what does the other text means, it's my native language, can translate it eventually. However, if I change it to:</p>

<p><code>cena_tesco = float(tesco/(tesco_g[:2]/10))</code></p>

<p>I get <code>TypeError float object is not subscriptable</code>.</p>

<p>You've defined <code>tesco_g</code> to be an integer by casting it with your 5th line.  Your TypeError is telling you that the <code>varname[:2]</code> syntax doesn't work because your type doesn't have indices.  To reframe what the interpreter is doing:
1. It reads <code>tesco_g[:2]</code>
2. It checks: does the type of <code>tesco_g</code> have a method for indexing up to the second element?
3. It doesn't find that method, and throws an error.</p>

<p>What is the <code>cena_tesco</code> line supposed to do?</p>

python python-3.x