OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why can't I compare a list to a float?

  • Thread starter Thread starter Crack09
  • Start date Start date
C

Crack09

Guest
I want to compare whether a transaction from an SQLite database exceeds a value. I get:

TypeError: '<' not supported between instances of 'list' and 'float'

I'm not sure whether using the filter function would be suitable since it needs a function and a sequence.

Code:
symbol = request.form.get("symbol")
stock_shares = request.form.get("shares")

#Identifies time of purchase
currTime = time.ctime()

# Yahoo Query for valid stock. Stores values in variables
info = lookup(symbol)
stock_symbol = info.get("symbol")
stock_price = info.get("price")

# Retrieves user data
user_cash = db.execute("SELECT cash FROM users WHERE id IN (?)", session["user_id"])
print("User cash: ", user_cash)

if user_cash < transactionTotal:
    return apology("Insufficient funds, 403")
<p>I want to compare whether a transaction from an SQLite database exceeds a value. I get:</p>
<blockquote>
<p>TypeError: '<' not supported between instances of 'list' and 'float'</p>
</blockquote>
<p>I'm not sure whether <a href="https://stackoverflow.com/questions...supported-between-instances-of-list-and-float">using the filter function</a> would be suitable since it needs a function and a sequence.</p>
<pre><code>symbol = request.form.get("symbol")
stock_shares = request.form.get("shares")

#Identifies time of purchase
currTime = time.ctime()

# Yahoo Query for valid stock. Stores values in variables
info = lookup(symbol)
stock_symbol = info.get("symbol")
stock_price = info.get("price")

# Retrieves user data
user_cash = db.execute("SELECT cash FROM users WHERE id IN (?)", session["user_id"])
print("User cash: ", user_cash)

if user_cash < transactionTotal:
return apology("Insufficient funds, 403")
</code></pre>
 

Latest posts

Top