Re: RE: [Tutor] Generating random in a user specified range.

Magnus Lycka magnus at thinkware.se
Tue Apr 27 12:57:35 EDT 2004


Chad Crabtree wrote:
> you need to strip the stuff from this.  I would do it thus.  
> import string
> bottom=int(string.strip(strbottom))
> top=int(string.strip(strtop))
> 
> this gets ride of any string whitespace strangeness that canot be converted
> to an integer.

There is no need to do that:

>>> 2 * int('    45     \n')
90

Besides, the string module is more or less made redundant since several
python versions back. Use " a string ".strip() instead of 
string.strip(" a string ")


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus at thinkware.se



More information about the Tutor mailing list