Jun-19-2020, 10:05 AM
Hi All,
Please could someone help with the error I am getting with my code
Description
The index of the first occurrence of the key in the provided list, if it is present, and -1 otherwise.
Please could someone help with the error I am getting with my code
Description
The index of the first occurrence of the key in the provided list, if it is present, and -1 otherwise.
Output:Input
[1, 2, 3, 4, 5, 6]
10
Solution output
-1
Expected output
-1
Test Case Passed.
Input
[1, 2, 4, 2, 3, 2, 3, 3, 6, 7]
3
Solution output
-1
Expected output
4
Test Case Failed
Sorry posted wrong code and error!!!!also just to let me know what changes to be done in the linked code to get the desired output.#input have been taken for you here import ast input_str = input() qlist = ast.literal_eval(input_str) value=input() dtlv= qlist.index(value) if (value in qlist) else -1 print(dtlv)I'm really new to python can anyone help me to correct the code