Oops, forgot my reply-to-all<br><br><div class="gmail_quote">On Tue, Jun 30, 2009 at 2:20 PM, Wayne <span dir="ltr">&lt;<a href="mailto:srilyk@gmail.com">srilyk@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="gmail_quote">On Tue, Jun 30, 2009 at 1:06 PM, Bob Rea <span dir="ltr">&lt;<a href="mailto:bob@telaugos.com" target="_blank">bob@telaugos.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


&lt;snip&gt;<div class="im"><br>
If I input my own name and dob, it works:<br>
bob@gandalf:~/python/MakingUse/Chapter05&gt; python code1.py<br>
Enter your first name:  Bob<br>
Enter your last name:  Rea<br>
Enter your date of birth, mm-dd-yyyy:  03-05-1943<br>
You can chose one of the following login names:<br>
1.   BobR<br>
2.   BobR53<br>
3.   RBob43<br>
4.   BRea66<br>
<br>
If I use the data listed in the book, it fails:<br>
bob@gandalf:~/python/MakingUse/Chapter05&gt; python code1.py<br>
Enter your first name:  Laura<br>
Enter your last name:  Jones<br>
Enter your date of birth, mm-dd-yyyy:  12-24-1980<br>
You can chose one of the following login names:<br>
1.   LauraJ<br>
2.   LauraJ2412<br>
3.   JLaura80<br>
<div>Traceback (most recent call last):<br>
</div>  File &quot;code1.py&quot;, line 67, in ?<br>
    fourth=fname[0]+lname+ age_func()<br>
TypeError: cannot concatenate &#39;str&#39; and &#39;NoneType&#39; objects<br>
<br>
What is going on here?</div></blockquote><div><br></div><div>Well the first line after &quot;Traceback&quot; give you the line of code and the filename. Which happens to be code1.py line 67.</div><div><br></div><div>TypeError is the type of error - specifically you tried to do something with incompatible types. In this case, adding together a string and NoneType.</div>


<div><br></div><div>I&#39;ll do a little digging, but my guess is you have a problem with your age_func() not returning any value.</div><div><br></div><div>HTH,</div><div>Wayne </div></div>
</blockquote></div><br>I was correct:<div><div>def age_func():</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>age=cur_year-year-1</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if month&lt;cur_month or (month==cur_month and day&lt;cur_day):</div>

<div><span class="Apple-tab-span" style="white-space:pre">                </span>age=age+1</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return str(age)</div><div><br></div><div>What happens if month is &gt; cur_month AND it&#39;s not my birthday?</div>

<div><br></div><div>You don&#39;t return a value. But if you simply unindent the &quot;return&quot; value then it should fix it:</div><div><br></div><div><div>def age_func():</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>age=cur_year-year-1</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>if month&lt;cur_month or (month==cur_month and day&lt;cur_day):</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>age=age+1</div><div>

<span class="Apple-tab-span" style="white-space:pre">        </span>return str(age)</div></div><div><br></div>Now regardless of whether age is incremented, it will return a string.</div><div>HTH,</div><div>Wayne<br>-- <br>To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn’t. - Primo Levi<br>


</div>