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
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
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
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
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