#!/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"
任何帮助/解释都会非常感谢
答案 0 :(得分:1)
你进行递归通话,但结果不会到达任何地方。你需要退货。例如:
return get_width()