0

Where I'm lacking in this python question

var = int(input()) if var > 10: print("High Five") if var < 1: print ("shh") if var > 1: print("Ra!"*var) My answer body and question is : https://www.sololearn.com/coach/20?ref=app

14th Sep 2024, 10:16 AM
Naina Kapoor
Naina Kapoor - avatar
2 Respuestas
+ 4
All conditions are getting tested no matter what the value is, whereas it should stop testing as soon as one condition is found to be true. Suppose var = 15. It will print both, "High Five" and "Ra"*var, because both conditions are true: 15>10 as well as 15>1. Solution: use elif
14th Sep 2024, 10:46 AM
Brian
Brian - avatar
+ 3
Thanks alot Brian ❣️👍
14th Sep 2024, 10:57 AM
Naina Kapoor
Naina Kapoor - avatar