Code Eval Challenge #20
Question: I joined code eval to improve my Python 3.5 programming. Code Eval is a
website, which offers challenges to any programmer looking to improve their
skills. Currently, I'm stumped on challenge #20.

* * *

Challenge #20 indicates that it needs the following:

Given a string write a program to convert it into lowercase.

INPUT SAMPLE:

The first argument will be a path to a filename containing sentences, one per
line. You can assume all characters are from the english language. E.g.

HELLO CODEEVAL This is some text OUTPUT SAMPLE:

Print to stdout, the lowercase version of the sentence, each on a new line.
E.g.

hello codeeval this is some text

* * *

I wrote the program for Code Eval. The strangest thing happened is that I
received an error after submitting my file. Here's what I programmed in Python
3.5:

    
    
    >Python 3.5 Code
    >Code Eval Challenge #20
    >t3xx3r
    >
    >text1 = "HELLO THIS IS CODEEVAL"
    >text2 = "This is some text"
    >
    >print(text1.lower() + '\n' + text2.lower())
    

I successfully submitted my third revision. It ended up with a "Failed" icon.
It seems that I did not understand the Code Eval Challenge. What was I missing
that did not fulfill their requirement(s)?

My first revision was partially 'filled' for Code Eval but here is my first
revision which was an actual partial success:

    
    
    >__author__ = 't3xx3r'
    >
    >text = 'HELLO CODEEVAL'
    >print(text.lower())
    

Yes, once again, so how did I get a partially successful code in revision 1
but not in the other revision?

I'm currently learning Programming Logic and will be moving on to Programming
Fundamentals I & II. The most difficult thing about Code Eval is that they're
asking for arguments (which are enclosed within functions, methods, etc.) but
I can't seem to find a way to successfully fulfill that challenge!


Answer: This is the basic code you could write:

    
    
    import sys
    
    test_cases = open(sys.argv[1], 'r')
    for test in test_cases:
        print(test.lower())
    
    test_cases.close()
    

Explanation: to access the first argument passed to the program, we need to
use `sys.argv`; index is `1` because at position `0` is the running path of
the script.

We iterate through each line in the file and print it in lower-case calling
the `lower()` method.

Finally we close the file to prevent wasting system resources by keeping the
file handle open.

