Python element "list[ ]" with variable length?
Good morning,
I'm currently coding a small project in Python. The idea is to first ask what possible answers there should be for a specific question. Then, these possible answers should be available to another person (using the same terminal) for selection.
So I would like a list to be created with the individual answer options, which will vary in length depending on the number of answer options, so that this list can be used later.
How do I do that? I've only recently started using Python, so I'm not very familiar with it yet…
Thanks in advance to everyone who writes an answer!
Hello.
The meaning of a list is that one wants to have a variable-length container.
Declaration:
Add item:
Select random element:
Delete item:
Otherwise, your text is not clear. Would you like to enter a question with the possibility of answering it and then someone who is asked the question and will be presented with the answers? Or how exactly was that supposed?
Thank you for the answer.
That’s exactly what you thought. Only the question is not entered in the list. It’s already predefined by the system.
Lists are inherently variable in length. You can add, remove elements at any time, …