Python Forum
please Help. TypeError: list indices must be integers, not str
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
please Help. TypeError: list indices must be integers, not str
#1
Hi. I give up, i just can't make this work.

If i type:
order_status_info = client.get_my_trades(symbol='LTCUSDT',limit=1)
print order_status_info

I get:
[{u'orderId': 6261652, u'isBuyer': False, u'price': u'153.99000000', u'isMaker': False, u'qty': u'0.33400000', u'commission': u'0.05143266', u'time': 1517695072404, u'commissionAsset': u'USDT', u'id': 1327699, u'isBestMatch': True}]

I need just the price so i type:

print order_status_info['price']

and it doesn't work: TypeError: list indices must be integers, not str

What am i doing wrong? Thanks
Reply
#2
Obviously, get_my_trades() returns a list of trades. In your case, the list has size 1 and the info item is the list's first element. Usei
trades = client.get_my_trades(symbol='LTCUSDT',limit=1)
order_status_info = trades[0]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to sort a list with duplicates and return their unique indices. Echoroom 3 3,455 Sep-23-2022, 07:53 AM
Last Post: deanhystad
  TypeError: string indices must be integers, not str hanieh 4 98,374 Jan-04-2021, 05:13 AM
Last Post: delonbest
  Convert a list of integers to strings? Cornelis 3 2,255 Nov-15-2019, 12:13 PM
Last Post: perfringo
  TypeError: string indices must be integers thecoziest 3 6,224 Sep-29-2019, 05:34 PM
Last Post: ichabod801
  TypeError: '<=' not supported between instances of 'list' and 'int' Leonzxd 4 62,877 May-18-2018, 09:49 AM
Last Post: Leonzxd
  create a 20 digit string, and cast to a list then add all the digits as integers nikhilkumar 2 6,370 Jul-19-2017, 04:53 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020