Python 缺少位置参数错误

Python 缺少位置参数错误,python,position,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 c

我正在测试我的代码,出现以下错误:

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
请输入客户名称:1
请输入客户的电话号码:01506890639
请输入组的大小:2
请输入膳食等级:4
是否要继续:是/否?否
访问的最大群体的队列为:2
回溯(最近一次呼叫最后一次):
文件“E:\CWtsk\code2.py”,第107行,在
main()
文件“E:\CWtsk\code2.py”,第13行,主目录
测量(姓名、电话、组号、分数、审核)
TypeError:mealrating()接受1个位置参数,但给出了5个
编码到这一点

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 ))
def main():
名称=[]
电话=[]
groupno=[]
分数=[]
回顾=[]
q=“y”
数据(姓名、电话、组号、分数、q)
maxi(组编号)
测量(姓名、电话、组号、分数、审核)
最差(姓名、电话、组号、分数、评论)
def数据(n、p、g、s、q):
而q!=“n”:
名称=输入(“请输入客户名称:”)
n、 附加(名称)
phone=“”
而len(str(电话))!=11:
尝试:
电话=输入(“请输入客户的电话号码:”)
除值错误外:
phone=“”
p、 附加(电话)
groupno=int(输入('请输入组的大小:'))
当groupno<1或groupno>20时:
groupsizes=int(输入('请输入有效的组大小:'))
g、 附加(组号)
score=int(输入('请输入膳食等级:'))
当分数<1或分数>10时:
分数=int(输入('请输入膳食等级-介于1和10之间:'))
s、 附加(分数)
q=输入(“是否继续:是/否?”)
#查找最大组大小
def maxi(组编号):
xGroup=groupno[0]
对于范围(0,len(groupno))中的x:
如果groupno[x]>xGroup:
xGroup=groupno[x]
打印(“\n”)
print('访问的最大组的队列为:'+str(xGroup))
#确定膳食等级,计算应用等级和优先级的数量
def测量(分数):
对于范围(0,len(分数))内的x:

如果分数[x]>=1,分数[x]=4,分数[x]=7,分数[x]为函数
mealrating
提供5个参数,但此函数只接受一个参数:
score
也在
mealrating
函数中,您拥有
review[x]=good
<代码>良好
未在任何位置定义,因此它将抛出错误。您需要将其更改为
“good”
。但是我怀疑你会想要保持收视率,所以你甚至不需要收视率,你可以按照你现在的方式来计算收视率。也许您需要后退一步,将问题分解为更小的部分,例如,分离不同类型的数据输入(姓名、电话号码、组大小、分级),以便您可以分别测试每个数据输入。另外,请注意,
maxi
只是
max(groupno)
。谢谢大家。这么多愚蠢的错误(x)