相关疑难解决方法(0)

for循环中的return语句

我一直在为学校的这项任务工作,我无法弄清楚为什么我不能让这个程序正常工作.我正在尝试让程序允许用户输入三只动物.它只允许我输入一个.我知道它与我在make_list函数中放置return语句有关,但无法弄清楚如何修复它.

这是我的代码:

import pet_class

#The make_list function gets data from the user for three pets. The function
# returns a list of pet objects containing the data.
def make_list():
    #create empty list.
    pet_list = []

    #Add three pet objects to the list.
    print 'Enter data for three pets.'
    for count in range (1, 4):
        #get the pet data.
        print 'Pet number ' + str(count) + ':'
        name = raw_input('Enter the pet name:')
        animal = raw_input('Enter the pet animal type:')
        age …
Run Code Online (Sandbox Code Playgroud)

python

7
推荐指数
3
解决办法
7万
查看次数

标签 统计

python ×1