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 odpowiedzi
+ 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 !