+ 1
Hello, I try to code cheer creator but cannot past the test case 3, can you help me to find the problem?
This is my code: distance = int(input()) if distance < 1: print("shh") if distance >= 1 or distance <= 10: print("Ra!" * distance) if distance > 10: print("High Five")
4 Respuestas
+ 2
"and" means we want distance to be >= 1 and <= 10 at the same time. "or" is is enough if one of the conditions is true.
Suppose distance = 12 and we use "or".
Then it would print Ra!*distance as 12 is >= 1 and it doesn't matter that 12 is not <= 10, as the first part would be true and that suffices.
+ 2
if distance >= 1 and distance <= 10
+ 1
Oohhh man thank you so much, it's really opening my mind 😳 so that's the logic. Thanks for the enlightenment
0
Thanks for the help, but can you explain why using "and" work but not "or"?