How to check if the number of lines in the file equal the number of characters in each of the lines?
<p>Reads the specified file and treats its contents as a list of strings (one per line).
Checks for the following conditions in the input file:</p>

<p>The file must exist and be available for reading. In other words, the call to open should not raise an exception.</p>

<p>The file must contain between 3 and 10 lines of text. That is, 3 is the minimum acceptable number of lines, and 10 is the maximum number of lines.</p>

<p>All lines must contain exactly the same number of characters.</p>

<p>Each line must contain between 3 and 10 characters. That is, 3 is the minimum acceptable number of characters, and 10 is the maximum. The number of characters per line does NOT have to equal the number of lines in the file.</p>

<p>The only acceptable characters are <code>'x'</code>, <code>'X'</code>, <code>'y'</code>, <code>'Y'</code>, and <code>'_'</code>.</p>

<pre><code>correct_string = False
while correct_string is False:

    string = input("Enter a string? ")
    if len(string) != len(string):
        print("Error: string must have the same number of characters.")
    else:
        incorrect_char = False
        for i in string:
            if i != "X" and i != "x" and i != 'Y' and i != 'y' and i != "_":
                incorrect_char = True
        if incorrect_char is False:
            correct_string = True
        else:
            print("Invalid Character. Contains characters other than 'X', 'x', 'Y' 'y',and '_'")
</code></pre>
