I can't run the code below because of the 7th line value = int(qty)*int(price)
. I can only run it if I use the int()
function inside the print()
function. Is there a way I can define it's an integer before I ask it to print? The same for float?
file = open("C:\\file.txt","r")
for mid in file:
qty = mid[38:53]
qty = qty.lstrip("0")
price = mid[75:86]
price = price.lstrip("0")
value = int(qty)*int(price)
trades = [qty,price,value]
print (trades)
file.close()
Shell-->
ValueError: invalid literal for int() with base 10: ''