Hi, I'm trying to make a program that prompts for input a certain number of times, like say the user inputs 5, it will prompt for other input five times. I get the number from the user, but how do I make a for loop that uses that variable instead of a number?

This is one of the things I tried, but it doesn't work. Any help please? Thank you!

num = raw_input("Enter a number: ")
list = []

for item in range(num):
    item = input("Enter: ")
    list.append(item)
num = int(raw_input("Enter a Number: "))
for x in range(0, num):
    raw_input()

That should provide a basis for your loop

Also, do not assign variables to built-in functions, such as 'list'. It's a bad idea to do

>>> num = raw_input("Enter a number: ")
>>> l = []
>>> for item in range(int(num)):
...     a = int(raw_input('Enter: '))
...     l.append(a)
...     
>>> l
[5, 6, 3, 4, 7]
>>>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.