+ 1
how can i do for just print the last element?
sum = 0 while True: x = input() #your code goes here if str(x)==str("stop"): break sum += int(x) print(sum)
2 odpowiedzi
+ 2
Alejandro Medrano
stop is already a string so no need to cast with str
input () function bydefault returns String value so no need to cast with str
print sum outside the loop but remember sum is already a function in python so don't declare a variable with name of sum.
+ 3
Put the print statement after the while loop instead of inside the loop