Home > Mobile >  TypeError: 'float' object is not subscriptable in Sqlite3 with Python script
TypeError: 'float' object is not subscriptable in Sqlite3 with Python script

Time:06-12

I have this...

        cursor.execute("SELECT BoughtPrice FROM Trades ORDER BY IndexNo DESC LIMIT 1")
        connection.commit()
        boughtprice = cursor.fetchone()
        print(boughtprice)
        
       
        boughtprice = cursor[0][0]
        print(boughtprice)

I am trying to turn the (0.6655,) result from the SQL query into just 0.6655 by removing the brackets and comma...

Any ideas how I can do that?

Thanks in advance... I am pulling my hair out!!

CodePudding user response:

As mentioned by Ftagliacarne above...

Have you tried with just one [0]?

Worked a treat!! :-)

  • Related