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

11th Nov 2021, 4:16 PM
Alejandro Medrano
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.
11th Nov 2021, 4:22 PM
A͢J
A͢J - avatar
+ 3
Put the print statement after the while loop instead of inside the loop
11th Nov 2021, 4:21 PM
Ben Eshchar
Ben Eshchar - avatar