Checking a word starts with specific alphabets python
<p>I have a string test_file1. I want to check taking a string from user if the string he/she enters starts with 'test'. How to do this in python? 
let args be =['test_file']</p>

<pre><code>for suite in args:
            if suite.startswith('test'):
                suite="hello.tests."+suite
            print(suite) // prints hello.tests.test_file
print(args) //prints ['test.file]' and not ['hello.tests.test_file']
</code></pre>

<p>Problem with code is you are not replacing the suite in args list with new created suite name .</p>

<p><strong>Check this out</strong></p>

<pre><code>args = ['test_file']
print "Before args are -",args
for suite in args:
    #Checks test word
    if suite.startswith('test'):
        #If yes, append "hello.tests"
        new_suite="hello.tests."+suite
        #Replace it in args list
        args[args.index(suite)]=new_suite

print "After args are -",args
</code></pre>

<p><strong>Output:</strong></p>

<pre><code>C:\Users\dinesh_pundkar\Desktop&gt;python c.py
Before args are - ['test_file']
After args are - ['hello.tests.test_file']

C:\Users\dinesh_pundkar\Desktop&gt;
</code></pre>

<p>Above can be also implemented using <strong>list comprehension.</strong></p>

<pre><code>args = ['test_file',"file_test"]
print "Before args are -",args

args = ["hello.tests."+suite if suite.startswith('test') else suite for suite in args]

print "After args are -",args
</code></pre>

python