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

1st Mar 2018, 1:52 PM
Anand Singh
5 ответов
+ 10
you need to change all if statements to elif , except the first one
1st Mar 2018, 2:02 PM
__Nick
__Nick - avatar
+ 8
yes but write the int < in one line
1st Mar 2018, 2:07 PM
__Nick
__Nick - avatar
+ 8
like this if 3>5: something elif 5<6: do something else
1st Mar 2018, 2:08 PM
__Nick
__Nick - avatar
+ 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])))))
1st Mar 2018, 4:20 PM
Louis
Louis - avatar
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")
1st Mar 2018, 2:05 PM
Anand Singh