Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我在Pythin 3.4.4中的代码工作正常,但现在它说Idex超出了范围_Python - Fatal编程技术网

Python 我在Pythin 3.4.4中的代码工作正常,但现在它说Idex超出了范围

Python 我在Pythin 3.4.4中的代码工作正常,但现在它说Idex超出了范围,python,Python,这是我创建的代码,它通常是有效的,但出于某种原因,它开始说 回溯(最近一次呼叫最后一次): 任何帮助都将不胜感激听起来这里需要一点检查,比如:如果行列表:或如果len(行列表)>0(如果您希望事情明确);就在引发错误的那一行之前。请格式化您正在获取的错误。请在该行linelist=row.split(',')之后执行打印(len(linelist))以查看列表中有多少项。列表中只有一项!听起来这里需要进行一些检查,比如:如果行列表:或如果len(行列表)>0(如果您希望事情明确);就在引发错误的

这是我创建的代码,它通常是有效的,但出于某种原因,它开始说

回溯(最近一次呼叫最后一次):


任何帮助都将不胜感激

听起来这里需要一点检查,比如:
如果行列表:
如果len(行列表)>0
(如果您希望事情明确);就在引发错误的那一行之前。请格式化您正在获取的错误。请在该行
linelist=row.split(',')
之后执行
打印(len(linelist))
以查看列表中有多少项。列表中只有一项!听起来这里需要进行一些检查,比如:
如果行列表:
如果len(行列表)>0
(如果您希望事情明确);就在引发错误的那一行之前。请格式化您正在获取的错误。请在该行
linelist=row.split(',')
之后执行
打印(len(linelist))
以查看列表中有多少项。列表中只有一项!
File "\\vfs\pupil$\2015\15fosterh\NEA 2019\Code\Code.py", line 75, in <module>
answer = linelist[1]
IndexError: list index out of range''
Welcome To The Quiz
You must Properly Capatalize
If the puncuation is not shown in a question
It doesnt need to be capataziled
<generator object <genexpr> at 0x00000000043AECA8>
W______ M_ By Hasley
 Enter your answer here:
  if selection in C:
      print("Welcome To The Quiz")
      print("You must Properly Capatalize")
      print("If the puncuation is not shown in a question")
      print("It doesnt need to be capataziled")
      score = 0
      b=[]
      filedata_list = []
      track = tuple(random.randint(0,20)for number in('songs.txt'))
      #print(track)
      datalist = (line.rstrip('\n') for line in open('songs.txt'))
      for row in datalist:
          linelist = row.split(',')
          question = linelist[0]
          #print(question)
           answer = linelist[1]
          #print(answer)
          number = linelist[2]
          #print(number)
          b = (question,answer,number)
           filedata_list.append(b)
      for line in filedata_list:
          print(line[1])
          response = input("Enter your answer here: ")
          if response == line[1]:
              score = score + 3
              print("Correct!")
           else:
                  print("WRONG!One more try")
                  response = input("Enter your answer here: ")
          if response == line[1]:
              score = score + 1   
              print("Good job! You scored: " + str(score))