Re: [Tutor] Problem formatting raw_input

2008-10-31 Thread Rich Lovely
The try: except: clauses allow for someone typing something like 'spam' when the program expects a number. It stops the program dying with an error message. --- Richard "Roadie Rich" Lovely Part of the JNP|UK Famille www.theJNP.com --- (Sent from my iPod - please allow for any typos: it's a v

Re: [Tutor] Problem formatting raw_input

2008-10-31 Thread bob gailer
Peter Anderson wrote: Dj Gilcrease wrote: The simple answer is to just use chr(int(inNum)) though here is how I would do it def convert_string_to_int(strInt): try: return int(strInt) except ValueError: return 0 def getNumbers(output): inNum = raw_input("Please ente

Re: [Tutor] Problem formatting raw_input

2008-10-31 Thread Kent Johnson
On Thu, Oct 30, 2008 at 11:03 PM, Peter Anderson < [EMAIL PROTECTED]> wrote: > My problem is with the actual entry of the ASCII codes. My solution has a > "if" test to remove the leading "0" from an input of say "033". With this > test the output of the decode is correct in printing "!". Without t

Re: [Tutor] Problem formatting raw_input

2008-10-30 Thread Peter Anderson
Dj Gilcrease wrote: The simple answer is to just use chr(int(inNum)) though here is how I would do it def convert_string_to_int(strInt): try: return int(strInt) except ValueError: return 0 def getNumbers(output): inNum = raw_input("Please enter an ASCII number\n(33

[Tutor] Problem formatting raw_input

2008-10-30 Thread Peter Anderson
Hi! I am teaching myself Python using John Zelle's excellent book Python Programming (ISBN: 1-887902-99-6). At the end of Chapter 4 - Computing with Strings is an exercise to convert an existing program to use a list to decode ASCII number input. My solution is shown below. My problem is wit