“ValueError:没有足够的值来解包(预期值为2,实际值为1)”是什么意思

2024-10-03 23:27:49 发布

您现在位置:Python中文网/ 问答频道 /正文

这是一个为3个筹款活动收集数据并将其显示在表中的任务,但我不断得到这个错误。你能确定错误是什么吗?你知道吗

def get_activityName(list12l):
  '''function to get the names of the activities'''
  activity = input("Enter the name of your {0} activity: ".format(list12l))
  while len(activity) > 10:
    print("Enter a name under 10 characters long")
    activity = input("Enter the name of your {0} activity: ".format(list12l))
  return activity

def get_pricing():
  '''this is the function that gets the hourly price for each activity'''
  validPrice = "a"
  while validPrice == 'a':
    price = float(input("Enter the hourly charge for this activity: "))
    if price > 5.99 or price < 0.99:
      print("This is an invalid price. Enter a valid price.")
    else:
      validPrice = "b"
  return price

def get_costs():
  table = []
  header = ['Activity, Charge per hour']
  table.append(header)
  list12l = ['first','second','last'] 
  for x in range(0,3): 
      across = []
      m = get_activityName(list12l[x])
      n = get_pricing()
      across.append(m)
      across.append(n)
      table.append(across)
  return table

def printFinalTable(table):
  for x,y in table:
    print("\t{0}".format(x,y))

def main():
    """runs all functions"""
    table = get_costs()
    print('\n')
    printFinalTable(table)
main()

Tags: ofthenameforinputgetdeftable