0
Iām looking for a more efficient code in the last part of the code to print ātrueā or āfalseā (last if.... )Any suggest? Thx
7 Answers
+ 1
thanks John, it works but code coach expect āfalseā, print(y==1) returns āFalseā ( or āTrueā)
0
can't open your link.
0
nb=int(input())
li=[int(input()) for i in range (nb)]
s=0
for k in range(1,nb):
s=li[k-1]+s
if li[k]>s:
y=1
else:
y=0
break
#print (li)
if y==1:
print('true')
else:
print('false')
0
the if statement can be remplaced with print(y==1).
0
you might also use print("true" if y==1 else "false").
0
I like it! thank you John š
0
you're welcome marco !