Lambdas- what Is Wrong? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Lambdas- what Is Wrong?

price = int(input()) perc = int(input()) res = (lambda x,y:(x/100)*y)(price, perc) print(res)

11th Jan 2024, 5:46 PM
Václav Dostál
Václav Dostál - avatar
8 Answers
+ 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.
11th Jan 2024, 6:38 PM
Lothar
Lothar - avatar
+ 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.
12th Jan 2024, 3:31 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 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.
11th Jan 2024, 8:39 PM
Jacob Morgunov
Jacob Morgunov - avatar
+ 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)
12th Jan 2024, 1:09 AM
Wong Hei Ming
Wong Hei Ming - avatar
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.
12th Jan 2024, 7:09 AM
Václav Dostál
Václav Dostál - avatar
0
Now I see diference, I was wrong in my previous comment. Wong Hei Ming answer Is right. Thank you all.
12th Jan 2024, 7:16 AM
Václav Dostál
Václav Dostál - avatar
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)
12th Jan 2024, 3:22 PM
Jacob Morgunov
Jacob Morgunov - avatar
0
Jacob Morgunov Wong Hei Ming it was a mistake i wanted to post on my questions
12th Jan 2024, 3:44 PM
Mac Anthony
Mac Anthony - avatar