insidesherpa / JPMC-tech-task-1

56 stars 352 forks source link

KeyError: 'ABC' #199

Open SohailAliCodes opened 4 years ago

SohailAliCodes commented 4 years ago

image

Issue: Getting this error after writing the instructed code Browser: Google Chrome Version 83.0.4103.106 (Official Build) (64-bit)

Tkapil1917 commented 4 years ago

after this command, "stock, bid_price, ask_price, price = getDataPoint(quote)" put "prices[stock] = price". worked for me.

ArvindOkram commented 4 years ago

Tried your style got error --> KeyError : 'DEF DEF '

Tkapil1917 commented 4 years ago

Hey Arvind, i think you forgot to put one parenthesis in the last line it should be: print ("Ratio %s" % (getRatio(prices['ABC'], prices['DEF']))). hope this solves your problem

ArvindOkram commented 4 years ago

Thanks, it works.

ghost commented 4 years ago

Screenshot (8)

key error 'ABC' ..please help me

ArvindOkram commented 4 years ago

here is my code that works: add prices[stock] = price after stock, bid_price, ask_price,price = getDataPoint(quote) as suggested by Tkapil1917 TASK1

namanbansal121294 commented 4 years ago

image

still getting this problem using python2

SHIVANILONDHE commented 4 years ago

image same problem

HuiHongOP commented 3 years ago

image

still getting this problem using python2

Hello, there. The "stock, bid_price, ask_price, price = getDataPoint(quote)", "prices[stock] = price" , and "print ("Quoted %s at (bid:%s, ask:%s, price:%s)" % (stock, bid_price, askprice, price))" should be inside the for loop of "for quote in quotes". Remember to indent them. One last thing is the " print ("Ratio %s" % getRatio(prices['ABC'], prices['DEF']))" should be inside of the "for in xrange(N):".

HuiHongOP commented 3 years ago

image same problem

"DEF" is not defined because key have not been set up yet inside of the "for quote in quotes:". However, you can fix this by moving the "print ("Ratio %s" % getRatio(prices['ABC'], prices['DEF']))" to outside of the "for quote in quotes:".