Check if an string has an integer in an if condition
<pre><code>file = open('Name.txt', 'r')
name =  str(file.read())
file.close()
</code></pre>

<p>In the file called 'Name.txt', the user will input a name. The program is to check whether or not the name is valid.</p>

<p>E.g:</p>

<p>1bob - is not valid</p>

<p>bob - is valid</p>

<p>Is it possible to do this with an if condition? </p>

<pre><code>def validate(my_file):
    return not any(x.isdigit() for x in open(my_file).read().strip())
</code></pre>

<p>The above function will return True when name is valid else False.</p>

python