2Time limit exceeded(TLE) Error in Python codeTime limit exceeded(TLE) Error in Python code

One thing you can do is increment `a`

and short as soon as you find a match. Currently you are calculating all of the possibilities before selecting out the lowest. All of that is unnecessary work when you just want the first match.

```
final = -1
for x in range(int(a), 1006):
if add(x) % 4 == 0:
final = x
break
print(final)
```

Source: link

I'm trying a code on Hackerearth which is to Find special number. A number n is said to be special if the sum of its digits is divisible by 4
For a given integer a, find a number such that:
n is a special number,
n>=a,
n is minimum possible.
I have created a code with all my knowledge and working absolutely fine and giving correct input but it is giving Time limit exceeded error

One thing you can do is increment a and short as soon as you find a match. Currently you are calculating all of the possibilities before selecting out the lowest. All of that is unnecessary work when you just want the first match.Source: link