## 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.

# I need help !!!!

I dont undertans how answer[0] can be True?

```import datetime
import random

class Quiz:
question = []

def __init__(self):
for _ in range(10):
question = random.choice(questions_type)
num1 = random.randint(1, 10)
num2 = random.randint(1, 10)
self.question.append(question(num1, num2))

# random questions with numbers from 1 to 1o self.question = quesiton
# add this question to self.Questions self.Questions.append(self.question)

def take_quiz(self):
self.start_time = datetime.datetime.now()  # log the start time self.start_time = time.time()

for question in self.question:  # ASK THE QUESTION

self.answers.append(self.ask(question))  # log if we have the questions right (True or False, Seconds)

self.end_time = datetime.datetime.now()  # log the end time

return self.summarie()  # show a summary

@staticmethod
question_start = datetime.datetime.now()  # log the start time

correct = True  # check the answer
print('good')

else:
correct = False

question_end = datetime.datetime.now()  # log the end time

return correct, question_end - question_start  # if the answer is right sent back True
# otherwise send back False
# send back the elapsed  time

def total_correct(self):
total = 0
total += 1

def summarie(self):
print('You got {} out of {} right'.format(self.total_correct(), len(
self.question)))  # print how many had right and de total of the questions

print("It took you {} second total".format((self.end_time - self.start_time).seconds))

Quiz().take_quiz()
```

Gotcha. Had the same question on a script I wrote before this one. Ok, this if statement is triggered if its expression is True, right? But I guess all the if statement really needs is the expression's value... so you could write "if True:" if you wanted an if statement that always was True. Try it in your IDLE... it works. Well, if answer[0] is "True" or "False", then you can just write "if answer[0]:". But let's take it a step further.... if I have a variable named "arg" and it was set to None... or it was 0 or it was an empty string, then if you typed "bool(arg)" it would return False. So you could also write "if arg:" if you wanted your code to do something only when "arg" had a truthy (as Kenneth likes to say) value.

Hi, Frank Here's some of my code for this video:

```import datetime
import random

class Quiz:

questions = []

def __init__(self):
# generate 10 random questions with numbers from 1 to 10
for _ in range(10):
num1 = random.randint(1, 10)
num2 = random.randint(1, 10)
question = random.choice(question_types)(num1, num2)
# add these questions into self.questions
self.questions.append(question)

def take_quiz(self):
# log the start time
self.start_time = datetime.datetime.now()

# ask all of the questions
for question in self.questions:
# log if they got the questions right
else:
# log the end time
self.end_time = datetime.datetime.now()

# show a summary
return self.summary()

correct = False
# log the start time
question_start = datetime.datetime.now()

answer = input(question.text + ' = ')

correct = True

# log the end time
question_end = datetime.datetime.now()

# if the answer's right, send back True
# otherwise, send back False
# send back the elapsed time too
return correct, question_end - question_start     # Notice that a tuple is being returned

def total_correct(self):
# return the total number of correct answers
total = 0
total += 1

def summary(self):
# print how many were answered correctly and the total number of questions
print('You got {} out of {} right.'.format(
self.total_correct(), len(self.questions)
))
# print the total time for the quiz
print('It took you {} seconds total.'.format(
(self.end_time-self.start_time).seconds
))

# Take a quiz
Quiz().take_quiz()
```

You see, the ask method returns a tuple, with the first item being "True" if the answer was correct. Now check out the take_quiz method. This method runs the game, using other methods and attributes as it needs. Note this section of code:

```        # ask all of the questions
for question in self.questions:
# log if they got the questions right
```

the answers attribute holds the return value of the ask method... so that means that "answers" is a list of tuples... you'll want to remember that.

So when the total_correct method below is run...

```    def total_correct(self):
# return the total number of correct answers
total = 0
total += 1