So I was solving this problem and I was getting correct outputs for what they were asking but It still marked it wrong as an answer. Here is my code link:
Please search the forums before posting a new thread: this comes up over and over again
1 Like
Your code is 95% correct, but it doesn’t consider the case when the input is a single digit number as pointed out by @ssjgz. I have added the necessary code to your code to fix the issue. Take a look and analyze it:
T = int(input())
for t in range(T):
list = [int(x) for x in str(input())]
#start of section added by me
if len(list) == 1:
print(2*list[0])
continue
#end of section added by me
del(list[1:-1])
print(sum(list))
Cheers