[Tutor] TypeError: unsubscriptable object
Kent Johnson
kent37 at tds.net
Wed Sep 3 22:37:36 CEST 2008
On Wed, Sep 3, 2008 at 3:44 PM, Rilindo Foster <webmaster at monzell.com> wrote:
> Hi! Long time reader, first time poster (I think).
>
> I am trying to do a comparison on a particular list item. The list in
> question comes in this pair:
>
> TotalStoreSales = Revenues + "," + Orders
> TotalStoreSales = TotalStoreSales.split(",")
These two lines could be just
TotalStoreSales = [Revenues, Orders]
> At this point, it has two values, both strings.
>
> Then I attempt to do a comparison like so:
>
> if (float(TotalStoreSales[0]) > 0):
> (does stuff)
>
> I know that it is converting into a float - that I verified.
>
> At any event, it keeps returning with this:
>
> Traceback (most recent call last):
> File "./getMivaStoreTransactions.py", line 143, in ?
> TotalSales = TotalSales + getStoreStats(d[0],AllSales)
> File "./getMivaStoreTransactions.py", line 120, in getStoreStats
> if (float(TotalStoreSales[0]) > 0):
> TypeError: unsubscriptable object
>
> Maybe I am missing something someplace. Help?
Is anything else happening between these two snippets? Try putting
print type(TotalStoreSales), TotalStoreSales
before the if statement.
Kent
More information about the Tutor
mailing list