缺少位置参数错误

时间:2014-03-10 13:55:18

标签: python position

我正在测试我的代码,但是我收到了这个错误:

Please enter the customer's name: 1
Please enter the customer's Phone Number:01506890639
Please enter the size of group: 2
Please enter the rating of the meal: 4
Do you wish to continue: Y/N?n

The largest group that visited had a cohort of:2

Traceback (most recent call last):
  File "E:\CWtsk\code2.py", line 107, in <module>
    main()
  File "E:\CWtsk\code2.py", line 13, in main
    mealrating(name, phone, groupno, score, review)
TypeError: mealrating() takes 1 positional argument but 5 were given

代码直到这一点

def main():
    name = []
    phone = []
    groupno = []
    score = []
    review = []
    q="y"


    data(name, phone, groupno, score, q)

    maxi(groupno)
    mealrating(name, phone, groupno, score, review)
    poorest(name, phone, groupno, score, review)

def data(n, p, g, s, q):
    while q != "n":
        name =  input("Please enter the customer's name: ")
        n.append(name)

        phone = ""
        while len(str(phone)) != 11:
            try:
                phone = input("Please enter the customer's Phone Number:")
            except ValueError:
                phone = ""
        p.append(phone)


        groupno = int(input('Please enter the size of group: '))
        while groupno < 1 or groupno > 20:
            groupsizes= int(input('Please enter a valid group size: '))
        g.append(groupno)



        score = int(input('Please enter the rating of the meal: '))
        while score < 1 or score > 10:
            score = int(input('Please enter the rating of the meal- between 1 and 10: '))
        s.append(score)

        q=input("Do you wish to continue: Y/N?")

#finding largest group size
def maxi(groupno):

    xGroup = groupno[0]
    for x in range(0,len(groupno)):
        if groupno[x] > xGroup:
            xGroup = groupno[x]
    print('\n')
    print('The largest group that visited had a cohort of:' + str(xGroup))


#determining the meal rating and counting number of applied ratings and priniting
def mealrating(score):
    for x in range(0,len(score)):


        if score[x] >= 1 and score[x] <= 3:
            review[x] = poor
            p = p + 1

        if score[x] >= 4 and score[x] <= 6:
            review[x] = good
            g = g + 1


        if score[x] >= 7 and score[x] <= 10:
            review[x] = excellent
            e = e + 1

    print('\n')
    print("The customer rated tonight's meal as:")
    print('%10s' % ('Poor:', p ))
    print('%10s' % ('Good:', g ))
    print('%10s' % ('Excellent:', e ))

0 个答案:

没有答案