.
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div bgcolor="#ffffff" text="#000000"><blockquote type="cite"><div>
<div class="h5">
Thanks Christian for your links and code!!!!<br>
<br>
</div></div><pre><fieldset></fieldset>
_______________________________________________
Tutor maillist - <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><div class="im">
To unsubscribe or change subscription options:
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a></div></pre>
</blockquote>
<br>
Below [1] is how I would write it, which is simply a re-factoring of
your code so it's cleaner and more compact. For calculating
execution time you can use the `timeit` module [2] and for more
in-depth analysis you can look at `profile` [3] and further to the
bare-bones `dis` [4].<br>
<br>
[1]<br>
>>> def splitWord(word, number):<br>
... x = []<br>
... for y in xrange(0, len(word), number):<br>
... x.append(word[y:y+number])<br>
... return x<br>
...<br>
>>> splitWord('google', 1)<br>
['g', 'o', 'o', 'g', 'l', 'e']<div class="im"><br>
>>> splitWord('google', 2)<br>
['go', 'og', 'le']<br>
>>> splitWord('google', 3)<br>
['goo', 'gle']<br></div>
>>> splitWord('google', 4)<br>
['goog', 'le']<br>
>>> splitWord('google', 5)<br>
['googl', 'e']<br>
>>> splitWord('google', 6)<br>
['google']<br>
>>> splitWord('google', 7)<br>
['google']<br>
<br>
[2] <a href="http://www.doughellmann.com/PyMOTW/timeit/" target="_blank">http://www.doughellmann.com/PyMOTW/timeit/</a><br>
[3]
<a href="http://www.doughellmann.com/PyMOTW/profile/index.html#module-profile" target="_blank">http://www.doughellmann.com/PyMOTW/profile/index.html#module-profile</a><br>
[4] <a href="http://www.doughellmann.com/PyMOTW/dis/" target="_blank">http://www.doughellmann.com/PyMOTW/dis/</a><br><font color="#888888">
<br>
<div>-- <br>
<p>Christian Witts<br>
Python Developer<br>
<br>
<i></i></p>
</div>
</font></div>
</blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.tricksfind.blogspot.com" target="_blank">www.tricksfind.blogspot.com</a><br><br>