0

How do I make something like

x = 5
while 0 < x
    b  = raw_input("something: ")

However each time it loops, I want it to change, like:
first loop - b = raw_input("something: ")
second loops - c = raw_input("something: ")
third loop - d = raw_input("something: ")
and so on.

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by nevets04
0

A for loop is easier for this.

for i in range(4):
    for item in ['a,b,c,d']:
        item = raw_input("something: ")
		
something: 7
something: 8
something: 9
something: 2
>>> item
'2'

>>> #If you whant to store all values put them into a list
>>> l = []
for i in range(4):
    for item in ['a,b,c,d']:
        item = raw_input("something: ")
        l.append(item)

		
something: 8
something: 9
something: 6
something: test
>>> l
['8', '9', '6', 'test']
>>>
0

Solved:

List = []
for x in xrange(5): List.append(raw_input(""))
0

Solved:

List = []
for x in xrange(5): List.append(raw_input(""))

Wow, I would have never guessed that from your original question.

Hint, variable names starting with a capital letter are by convention used for class names.

0

Wow, I would have never guessed that from your original question.

Hint, variable names starting with a capital letter are by convention used for class names.

Lol. Yeah, I wasn't really sure how to phrase that question

Edited by nevets04: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.