Python Forum
Computational linguistic program - Need some help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Computational linguistic program - Need some help
#4
I don't get an index error when I run your code with those two sentences. But looping through indexes causes just sort of these problems. It also seems that you are looping through questions twice, once with the for loop on 14, and once with the while loop and i on line 18. If you have a list of questions, and a list of the corresponding words that are the answers to those questions, you should do it with zip:

correct = 0
for question, word in zip(questions, words):
    print(question)
    answer = input("Which article? ")
    if answer == word:
        print("Right answer")
        correct += 1
    else:
        print("Wrong answer")
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Computational linguistic program - Need some help - by ichabod801 - May-01-2019, 05:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Advanced Algorithms and Computational Models hafedh 4 2,367 Aug-31-2020, 06:37 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020