Question: I continue to work on an assignment and I have another problem that has taken much time to overcome without success. The question is as
I continue to work on an assignment and I have another problem that has taken much time to overcome without success. The question is as follows:
Implement the Function getsrc
Implement the function according to the specification. An ideal solution will use firstinsidequotes as a helper. Use the test script testcurrency.py to aid your development before checking your answer below.
My answer is:
pos introcs.findstrjson
pos introcs.findstrjson pos
return jsonpos:pos
I get the following error message:
Call getsrcsuccess: false, src: dst: "error": "The rate for currency EUF is not present." returned not the expected
Another answer based on an answer from your experts on a previous occasion is:
def getsrcjson:
Returns the src value in the response to a currency query.
Given a JSON string provided by the web service, this function returns
the string inside string quotes immediately following the substring src
For example, if the json is success: true, src: United States Dollars",
dst: Euros", "error": then this function returns
United States Dollars' not United States Dollars"
On the other hand, if the json is success: false, src:dst:
"error":"Source currency code is invalid." then this function returns
the empty string.
Parameter json: a json string to parse
Precondition: json is a string provided by the web service ONLY enforce the type
start json.findsrc lensrc # Find the starting index of the value
end json.find start # Find the ending index of the value
return jsonstart:end # Extract and return the value between the quotes
I get the following error message:
Call getsrcsuccess: true, src: United States Dollars", dst: Euros", "error": returned not the expected United States Dollars'.
I also tried the following:
start json.findsrc lensrc # Find the starting index of the value
end json.find start # Find the ending index of the value
return jsonstart:end # Extract and return the value between the quotes
I still get the error following message:
Call getsrcsuccess:true, src: United States Dollars", dst: Euros", "error":"" returned United States Dollars', not the expected United States Dollars'.
It is interesting that even your answer from a previous occasion still gives an error message. I would appreciate your help as I have wasted sufficient time on this. Thank you...
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
