+ 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")

27th Jun 2022, 9:43 AM
Arka Style
Arka Style - avatar
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.
27th Jun 2022, 10:10 AM
Lisa
Lisa - avatar
+ 2
if distance >= 1 and distance <= 10
27th Jun 2022, 9:47 AM
Lisa
Lisa - avatar
+ 1
Oohhh man thank you so much, it's really opening my mind 😳 so that's the logic. Thanks for the enlightenment
27th Jun 2022, 10:45 AM
Arka Style
Arka Style - avatar
0
Thanks for the help, but can you explain why using "and" work but not "or"?
27th Jun 2022, 9:49 AM
Arka Style
Arka Style - avatar