 The code incorrectly calculates the sum of the digits of the number. For example, if you enter 157, then the output will be LOCK | Sololearn: Learn to code for FREE!

0

# The code incorrectly calculates the sum of the digits of the number. For example, if you enter 157, then the output will be LOCK

https://code.sololearn.com/c9JM7vSLRwvt/?ref=app

+2

The problem is actually your second term bracket. You shouldn't and two numbers, because it will return True/False (1 and 1) == True # True is also 1 so instead you can just remove the bracket and the and c // 100 + c // 10 + c % 10 == 13: however, the second term will be wrong, so you need to adjust it a bit c // 100 + c // 10 % 10 + c % 10 == 13: so let's say 157, 157 //10 = 15 15 % 10 = 5, which is the number you want Another alternative and maybe easier way is to loop the string and plus the int of each character c = input() # didn't convert to int here total = 0 for char in c: total += int(c) And here is the standard way everyone getting the sum of tbe digits c = int(input()) total = 0 while c > 0: total += c % 10 c //= 10

+1

Polina Voqy What do you expect and what are you doing here? https://code.sololearn.com/cw6Cz4ogRgPk/?ref=app

+1

0

It is lock. When you input number less than 100 and more than 999 then you'll got FALSE. If sum of digits of a number is 13 output is ENTER. In other occasions LOCK. But when I write 157 or 247 and also some more, it outputs LOCK

0

Thanks for the explanation