+ 11
Mathematics (Code Coach)
Wrote code "Mathematics", error in tests 4 and 5. Who knows what is in these tests?
15 Réponses
+ 3
Konstantin K I think I got this problem. Please try at the end of your code write:
if k == 1:
print("none")
but the last line with tab distance from left.
Happy coding!
+ 7
Rik Wittkopp Yes and free access for 30 days after completing BTS
+ 7
McInventor29 I use the function ival() too.
+ 6
The tests are hidden to force you to think about scenarios that are within the brief, but may not be immediately obvious.
This approach helps develop logic thinking.
PS: Is 'Mathematics' only available to pro?
+ 6
JaScript Yes of course.
+ 6
JaScript I understood what the problem is, I fix the code
+ 6
I fixed the code, but still there was an error in test 4.
+ 6
JaScript I need to know that in test 4.
+ 6
Changed the code, everything works. What was the problem I did not understand. https://code.sololearn.com/cts0oL4WuJrF/?ref=app
+ 2
I was stuck on this one too, but I found a really simple way to solve it.
(Hint: use the function eval(). )
Also, I’m using SoloLearn Pro because of the BTS challenge.
+ 1
Did you test your code on the Playground and know how it works?
+ 1
Konstantin K And as I understand what was asked, your code does it. Where is your attempt?
+ 1
What can be done without your attempt, what do you expect?
+ 1
answ = int(input())
math_expr = input().split()
for i in math_expr :
if eval(i)==answ:
print("index " + str(math_expr.index(i)))
break
else :
print('none')
+ 1
result = int(input())
expr = input().split(' ')
bool = [eval(expr[i]) == int(result) for i in range(len(expr))]
print("index "+str(bool.index(True)) if True in bool else "none")