我的代码的show_list
功能不起作用。我收到一条消息,指出'multiples'
未定义,但我无法确定问题。有人可以请审查和建议,以什么是我做错了。帮助功能不起作用
def main():
input1 = int(input("enter the low integer: "))
input2 = int(input("enter the high integer: "))
input3 = int(input("enter the integer for the multiples: "))
show_multiples(input1, input2, input3)
print ("List was created")
def show_multiples(input1, input2, input3):
num_range = range(input2, input1, -1)
multiples = []
for num in num_range:
if num % input3 == 0:
multiples.append(num)
return multiples
show_list(multiples)
def show_list(multiples):
elem = len(multiples)
average = sum(multiples)/elem
num_range = range(input2, input1, -1)
print ("the list has", elem, "elements.")
for num in num_range:
if num % input3 == 0:
print (num, end=" ")
print ("Average of multiples is ", average)
main()
感谢您的反馈 – user3988476 2014-08-29 02:02:18