Time limit exceeded

Why Time limited exceeded even though answer is correct? Pls tell how to correct it. I have read some answers but am not able to understand as I am a beginner in python…

In Competitive Programming we must take Care about “Time Complexity” and “Space Complexity” , If your answer is correct but the “Time Taking to run your code is Much High” Then you will be thrown a message “Time Limit Exceed”

Try To write simple codes which Run In less time and takes Less space. It will make your algorithm more efficient,