15,041,788 members
1.00/5 (1 vote)
See more:
the problem is in a survey/test creation and execution program.it lets the person choose how many people will be doing it and the questions are in one input using for loops but it needs a way to sort the answers to each question in lists
for each person.is there a way to create lists depending on how many people are taking the survey and append the lists with the answers that those people give?

What I have tried:

context-this is the entire programm up to the point where the answer goes:

Python
```<pre>class colour:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'

print(colour.BOLD + colour.UNDERLINE + 'Survey Maker and Executer' + colour.END)
print(colour.BLUE + colour.BOLD + '''type "help" for a step by step description of how this program works.
type "next" to continue.
Have Fun!
''' + colour.END)
help_or_next = input("type help or next: ")
if help_or_next == ("help").lower():
print(colour.YELLOW + colour.BOLD + "description of how the program works" + colour.END)
print("""
part#1 = this part of the survey creation will ask you to input the number of
people you want to take this survey. it will then ask you to input titles or names for each of these
purely to have a heading under the results of each survey.
part#2 = this part of the survey creation will ask you how many questions will be in your
survey then, based on that it will a you to type out each question one at a time.
part#3 = this part will be a final stopping point before the survey begins
""")
print(colour.BOLD + colour.GREEN + "part#1- number of surveys and names" + colour.END)
i = 1
while i < 2:
number_of_surveys = input("number of surveys to be done up to 10: ")
limit = ("abcdefg")
if int(number_of_surveys) == 1:
limit = ("a")
i = 3
elif int(number_of_surveys) == 2:
limit = ("ab")
i = 3
elif int(number_of_surveys) == 3:
limit = ("abc")
i = 3
elif int(number_of_surveys) == 4:
limit = ("abcd")
i = 3
elif int(number_of_surveys) == 5:
limit = ("abcde")
i = 3
elif int(number_of_surveys) == 6:
limit = ("abcdef")
i = 3
elif int(number_of_surveys) == 7:
limit = ("abcdefg")
i = 3
elif int(number_of_surveys) == 8:
limit = ("abcdefgh")
i = 3
elif int(number_of_surveys) == 9:
limit = ("abcdefghi")
i = 3
elif int(number_of_surveys) == 10:
limit = ("abcdefghij")
i = 3
else:
print("i don't understand that, please try again")
for charecters in limit:
name_or_headings_input = input("Enter the names/headings of the different survey attempts 1 at a time in the desired order: ")
print(colour.BOLD + colour.GREEN + "part#2- question creation" + colour.END)
questions = []
Number_of_questions = input("input a number up to 10 for the questions to be in survey: ")
if int(Number_of_questions) == 1:
limit = ("a")
elif int(Number_of_questions) == 2:
limit = ("ab")
elif int(Number_of_questions) == 3:
limit = ("abc")
elif int(Number_of_questions) == 4:
limit = ("abcd")
elif int(Number_of_questions) == 5:
limit = ("abcde")
elif int(Number_of_questions) == 6:
limit = ("abcdef")
elif int(Number_of_questions) == 7:
limit = ("abcdefg")
elif int(Number_of_questions) == 8:
limit = ("abcdefgh")
elif int(Number_of_questions) == 9:
limit = ("abcdefghi")
elif int(Number_of_questions) == 10:
limit = ("abcdefghij")
else:
print("I don't understand that, please try again.")
for charecters in limit:
questions_input = input("Enter your questions one by one in order: ")
questions.append(questions_input)
print(colour.BOLD + colour.GREEN + "part#3 - starting" + colour.END)
print("make sure the people who are taking the survey/quiz are taking it in the order you gave.")
start = input("type start when you are ready: ")
for each_survey in range(0, number_of_surveys):
for each_question in questions:
Python
`<pre lang="Python">`
Posted
Updated 7-Apr-21 2:35am
v3
Richard MacCutchan 7-Apr-21 6:47am

There is not really enough information to fully understand the question. In the above code you throw away all the answers which is obviously not what you want.

## Solution 1

You can simplify that code considerably, and also correct the saving of numbers as strings:
Python
```names_or_headings = []
i = 1
while i < 2:
number_of_surveys = int(input("number of surveys to be done up to 10: ")) # convert to int here
if number_of_surveys == 0 or number_of_surveys > 10:
print("i don't understand that, please try again")
else:
i = 2
for x in range(number_of_surveys):
name_or_headings_input = input("Enter the names/headings of the different survey attempts 1 at a time in the desired order: ")

print(colour.BOLD + colour.GREEN + "part#2- question creation" + colour.END)
questions = []
Number_of_questions = int(input("input a number up to 10 for the questions to be in survey: "))
if Number_of_questions == 0 or Number_of_questions > 10:
print("I don't understand that, please try again.")
else:
for x in range(Number_of_questions):
questions_input = input("Enter your questions one by one in order: ")
questions.append(questions_input)

print(colour.BOLD + colour.GREEN + "part#3 - starting" + colour.END)
print("make sure the people who are taking the survey/quiz are taking it in the order you gave.")

#
# the following code fails as "item" has not been declared anywhere
#
start = input("type start when you are ready: ")
for each_survey in range(number_of_surveys):
for each_question in questions:

Apart from the fact that `item` is not defined (you probably meant to use `each_question`), the answer is not saved anywhere.
v2