Hi @mudassir, and welcome!
Please read the pinned post about how to format code when pasting it into your posts: About the Python Help category
I do not have an answer for your question, but proper formatting will make your code more readable so it is easier for others to help you.