+ 3
Key Error in list when surely key exist in the list.
It's Safety Deposit Boxes problem l=input().split(",") print ((l.index(input())+1)*5) Why it's showing key error? Input: gold,diamonds,documents,Declaration of Independence,keys Declaration of Independence Output: Key error Declaration of Independence is not in list
2 odpowiedzi
+ 1
I get an output of 20.
The index of "Declaration of Independence" = 3....
you then add 1 then you multiplied by 5.
Are you copying and pasting your inputs when your running the prog as you might be include an extra space without realising it. I got a "valueerror" not "keyerror" when I did exactly that.
I would put the value directly into the code (just for testing) rather then taking them as user inputs so as to avoid errors due to typos etc.
+ 1
What are your input?
What are you trying to do...some people (|including me) don't know the "Safety Deposit Boxes problem"