0
How to put with using "if" and "elif" more then two different adnotations, depend of users number choice?
I have code: if x+y <= 20: print("ok") elif x+y >= 21: print("better") And it is working fine but i want to have something like that, or even more options with adnotations to choose: if x+y <= 20: print("ok") elif x+y >= 21 and x+y <=50: print("better") elif x+y >=51: print("the best") How to do that?
4 Antworten
+ 3
If I understand your question, what you've written is perfectly fine. Have you tested it?
+ 1
You can probably just do
elif x+y <= 50:
since x+y will automatically be >= 21 if it is not <= 20 (assuming x+y is an integer). I can think of no other reason it wants you to simplify.
0
Yes, and the interpreter underline
x+y >= 21 and x+y <=50:
he want me to simplify
0
Ok thank You:)