0
What can I do to print only one result?
x=input("") if int(x)<=20: print("Less than 20") if int(x)<=25: print("Less than 25") if int(x)<=30: print("Less than 30") else: print("Done")
5 Réponses
+ 10
you need to change all if statements to elif , except the first one
+ 8
yes but write the int < in one line
+ 8
like this
if 3>5:
something
elif 5<6:
do something else
+ 1
x=float(input(""))
print('{}'.format('Done' if x>=30 else('Less than '+str(min([y for y in [20,25,30] if y>x])))))
0
# Like that one
x=input("")
if int(x)<=20:
print("Less than 20")
elif
int(x)<=25:
print("Less than 25")
elif
int(x)<=30:
print("Less than 30")
else:
print("Done")