Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

I'm stuck in at least three spots, for a DMV license test program. Can someone take a look and give me some pointers?

I have hashtagged the three areas that I think I need help in but I may be wrong in some other areas. I had most things working but needed to add third txt file(DMV.txt) according to the projects instructions. So, I modified some things, in order to be complying with the projects requirements. The original way I had it, was only giving me Incorrect results, and Johns answers aren't lining up under Johns answers. Anywho, someone please take a look please and point me in the right direction, please.

def main():
    submitted = ['A','D','C','A','C','A','D','C','A','D','A','C','B','D','A','C','C','A','D','B']
    correct = ['1.  B', '2.  D', '3.  A', '4.  A', '5.  C', '6.  A', '7.  B', '8.  A', '9.  C', '10. D', '11. B', '12. C', '13. D', '14. A', '15. D', '16. C', '17. C', '18. B', '19. D', '20. A']
    correct_count = 0
    incorrect_count = 0
    results = getResults(submitted, correct)


def getResults(submitted, correct):
    correct_count = 0
    incorect_count = 0
    while submitted == correct:
      print ('Total Correct: ')
    elif submitted != correct
      print ('Total Incorrect: ')
    for score in  #***I'm stuck for what to put here(how to word it correctly),or if this is even how I should write it.


def writeToFile(submitted):
    submitted = ['A','D','C','A','C','A','D','C','A','D','A','C','B','D','A','C','C','A','D','B']
    outfile  = open('johns_answers.txt', 'w')
    for item in submitted:
      outfile.write(item + '\n')
    outfile.close()
    infile = open('johns_answers.txt', 'r')
    submitted = infile.readlines()
    infile.close()
    sub_count = 0
    while sub_count < len(submitted):
      submitted[sub_count] = submitted[sub_count].rstrip('\n')
      sub_count += 1
    print ('The answers you submitted were: ', submitted)
    print ('******************************************************************************************')

def writeToFile(correct):
    correct = ['1.  B', '2.  D', '3.  A', '4.  A', '5.  C', '6.  A', '7.  B', '8.  A', '9.  C', '10. D', '11. B', '12. C', '13. D', '14. A', '15. D', '16. C', '17. C', '18. B', '19. D', '20. A']
    outfile  = open('valid_answers.txt', 'w')
    for item in correct:
      outfile.write(item + '\n')
    outfile.close()
    infile = open('valid_answers.txt', 'r')
    correct = infile.readlines()
    infile.close()
    correct_count = 0
    while correct_count < len(correct):
      correct[correct_count] = correct[correct_count].rstrip('\n')
      correct_count += 1
    print ('The correct answers are: ', correct)
    print ('******************************************************************************************')

def writeToFile(results)
    correct_count = 0
    incorrect_count = 0
    outfile = open('DMV.txt','w')
    print ('  Correct DMV answers     Johns answers')
    print ('Answer          Correct/Incorrect')
    for answer, correct in zip(submitted, correct):
            outfile.write(item+ '\n')
            outfile.close()
        infile = open('DMV.txt', 'r')
        getResults = infile.readlines()#I'm also stuck here, I'm nor sure that this is how this should be worded.
        infile.close()
        if answer == correct:#I'm not sure if I really need this here, with the def getResults section added above(I had this here originally but I've made some modifications, plus I think it's incorrectly
                             #wrote anyway, I was only getting incorrect results).
            correct_count += 1
            print (correct, answer ,'                             = Correct')
        else:
            answer != correct
            incorrect_count += 1
            print (correct, answer ,'                             = Incorrect')

main()