A cybersecurity hackathon.
There were two types of programming questions, one was related to advanced coding and the other one was related to ML Classification.
You are required to write a Python function to read a file from the given. The file contains text lines and your function has to read each line and detect if the line is a palindrome along with count the number of characters.
If the line is a palindrome, then record the line number of this line in the file. The line number starts from 1. Not all lines are necessarily palindromes. Finally, count all the number of palindromes. Your program needs to return a dictionary with the line number of a palindrome and number of characters in the palindrome (excluding blank spaces) along with a string representing the status of reading the file. If the file has no palindrome, the dictionary returned should contain {0:0} If the URL is correct and the file is a txt file, the status message should be "file ok". If the URL is correct but the file is not a txt file, the status message should be "file is not a text file". If the URL is not a valid URL, the status message should be "the URL is incorrect". Input Specification: The string value representing the URL of the file. Output Specification: Return an object of the "Result" class. The object should have: a dictionary with the key as the line number and value as the count of the number of characters a string representing the status message
Example Input:
Output:
output1: {2:4, 5:7, 6:30, 8:30, 9:9, 12:5, 14:11}
output2: "file ok"
Solution: The Solution is given in the location /coding/q1.py