Can you create an If statment where which next step the program takes is based upon the number of items in a list?

29 views Asked by At

there I am creating a rather simple quiz system and at the end of the quiz, I want all of the user's answers to be displayed on the screen and saved into a csv file. Currently, their score is saved and they are told if they got the answer right or wrong after each question.

The questions are in a csv file and they are randomly selected based on a list with the numbers 1 to 7 in it,this is the list that I want to use to check what answer they are on.

What I want to do is after every question save what the question is and the answer so esentianlly.

if there are 6 numbers in list then saved question as question 1 and save answer as answer 1 else if there a 5 numbers in the list then saved question as question 2 and save answer as answer 2 and then so on

I know that it isn't very clear, but to be honest I am not sure how to word it, I do have code if needed, but since the question is general, I don't think it will be needed.

Ask me any questions and thank you for your time.

1

There are 1 answers

0
Bryce Wellman On

so do you need code that tells you how many items are in a list? If so it would simply be len(list), if you had 5 in the list you could use an if statement to say if there are 5 do this, elif this and so on.