just started playing with python came across a little problem simple example area of square with exception handling for wrong input works when integers are correctly input --but should I input and string or char-I get Traceback (most recent call last): File "ex3.py", line 29, in area = width * length TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
#!/usr/bin/python
def error():
print "no parameter entered - please enter parameter"
def get_width():
width = None
try:
width = int(raw_input("please enter width of the room in meters: "))
return width
except:
error()
get_width()
def get_length():
length = None
try:
length = int(raw_input("please enter length of the room in meters: "))
return length
except:
error()
get_length()
print "\nExercise 3: Area of a Room"
width = get_width()
length = get_length()
area = width * length
print "The area of a room with a width of "+str(width)+" and a length of "+str(length)+" is "+str(area)+" squared meters\n"
any help/explanation would be great thanks