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

Time quiz app extra credit

I wrote in addition to timed quiz for question breakdown:

return 3 instead of 2 arguments from ask() -

return correct, answer, question_end - question_start

then add onto summary

def summary(self):
    #print answers == True
    print("You got %s out of %s right." % (self.total_correct(),len(self.questions)))
    print("It took you %s seconds to complete." % (self.end_time - self.start_time).seconds)
    #if input("wana breakdown?") == 'y':
        return self.intense_summary()

def intense_summary(self):
    for question,answer in zip(self.questions, self.answers):
        if answer[0] == False:
            print("\n"+question.text +" = "+ str(answer[1]) + " is " + str(answer[0]))
            print("Correct answer is " + str(question.answer))
            print("It took you %s seconds to answer" % (answer[2]).seconds)

        elif answer[0] == True:
            print("\n"+question.text +" = "+ str(answer[1]) + " is " + str(answer[0]))
            print("It took you %s seconds to answer" % (answer[2]).seconds)

Im not sure if its cos its python 2 or using liclipse but the #if input("wana breakdown?") == 'y': wouldnt run so I just run the breakdown automatically.

also python 2 does not unpack !!! learnt this the hard way with print(*answer) ... thought I was going insane

ps. my indentation is messed up to make it print it nicely for the forum :)

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Python 2 totally unpacks, but, in Python 2, print is a keyword, not a function. So you're trying to unpack a tuple into a tuple in a weird spot so, yeah, it's invalid syntax.

The input() probably isn't working because Python 2 uses raw_input for what Python 3 uses input. Python 2's input is actually pretty insecure so don't use it.