I am having trouble inputting data into a list with unknown amount. Also afterwards, I need to be able to then reprint the list in reverse while not using the reverse function.
Thank You
lengthOfList=(int(input(‘How many numbers do you want to list(1-10)?:’)))
myList=list(range(0,lengthOfList))
for INDEX in range (0,lengthOfList,1):
print(‘Enter number ‘, myList[INDEX]+1,’:’)
If I’m understanding your question correctly I think you want to be able to add numbers to a list regardless of its size? Lists in python don’t have a fixed size so you can just initialize it like this:
How do you input numbers for an unknown amount of times? I created the question “How many numbers do you want to enter?” The user can type in any number from 1-10. If the user types 3 for example, I need it to ask “Enter your first number:” Then “Enter your second number:” etc. I then want to use those numbers to come up with a sum, average, etc. So, I need each inputted number assigned a unique variable (I assume). I will not know ahead of time how many variables I will need. I am using the list function too [ ].
Just a quick meta-question: this isn’t homework, is it? Some people don’t take kindly to (unknowingly) helping with homework, and the question sounds like something that might be set as homework.