0
Lambdas- what Is Wrong?
price = int(input()) perc = int(input()) res = (lambda x,y:(x/100)*y)(price, perc) print(res)
8 Respuestas
+ 3
Václav Dostál ,
> you should give at least a task description, and a sample with 2 inputs, the output of the code and what concers you have.
> if the task is from a sololearn tutorial / exercise, please mention these.
+ 2
Mac Anthony
This post is about Python.
If you have question related to JS please open a new post and give a proper tag to your question.
People interested in JS will reply you once they see your post.
+ 1
To be honest I really don't see the problem in this code.
It does exactly what it suppose to. I remember this task, it is from the Python Developer course.
Here's the code I use:
price = int(input())
perc = int(input())/100
res = (lambda x,y:x*y)(price, perc)
print(res)
It worked for me.
I'm curious though to know what is the issue with your code.
+ 1
It shows the difference
price = 80
perc = 7
# Your solution
res_1 = (lambda x,y: (x/100)*y)(price, perc)
# Jacob's solution
res_2 = (lambda x,y: x * y / 100)(price, perc)
print('Your solution:', res_1, '\nJacob's solution:', res_2)
0
Thank you Jacob, yes it Is the task from Python Developer course. In that case I Have to say: that Is how to NOT calculate percent.
0
Now I see diference, I was wrong in my previous comment. Wong Hei Ming answer Is right. Thank you all.
0
Mac Anthony I'm not sure, I focus learning Python, but it look like Java.
If word[i] is what I think it is (a String value), is it fine to use += To concatenate? (Line 9)
0
Jacob Morgunov Wong Hei Ming it was a mistake i wanted to post on my questions