What is the indented lines directly below
try:called/reffered to? I have heard "the body oftry:" and "the expression oftry:". Please clarify. (See user - poke´s - answer)What is
try:,except:,while:etc. reffered to? LikeTrueandFalseare reffered to as "statements". (See user - poke´s - answer)Is there any reason to change function1 into function2. The only difference between them is
ValueError. The functions are only supposed to force the user to input an integer. (See user - poke´s - answer)
function1
def get_integer(LIMIT_PROMPT):
while True:
try:
return int(input(LIMIT_PROMPT))
except:
pass
I have seen lots of except statement: and in the body/expression there is a piece of code that does something if an error occured in the body/expression of try:
I have used this particular function in two programs and have not run into any trouble.
function2
def get_integer(LIMIT_PROMPT):
while True:
try:
return int(input(LIMIT_PROMPT))
except ValueError:
pass