0

Why my code giving me wrong answer or is something wrong with my code?

I just want to fetch small value but when i try it with third value it doesn’t work as i want and it should - first_num = int(input("input first number : ")) second_num = int(input("input second number : ")) third_num = int(input("input third number : ")) small_value = 0 if first_num < second_num and third_num : small_value = first_num elif second_num < first_num and third_num: small_value = second_num elif third_num < first_num and second_num: small_value = third_num print(small_value) output -> input first number : 5 input second number : 6 input third number : 3 5

26th Jan 2021, 2:13 PM
Balraj Singh
4 odpowiedzi
+ 8
Balraj Singh , you can not use conditional statement like this: if first_num < second_num and third_num : # <<<<<<< it has to be this way for all conditionals: if first_num < second_num and first_num < third_num : # <<<<<<
26th Jan 2021, 3:08 PM
Lothar
Lothar - avatar
+ 2
What are you expecting ?like the inputs and output .
26th Jan 2021, 2:22 PM
Abhay
Abhay - avatar
+ 1
when I input third value as smallest value then it should print third value but it is not working that way. (Thanks for Reply Abhay )
26th Jan 2021, 2:27 PM
Balraj Singh
+ 1
Thank You so much Lothar. it worked this way. 😊
26th Jan 2021, 3:18 PM
Balraj Singh