Letss say the user wants to input 100 things; but I don't want to make my script have 100, x = raw_input('')
, is there away to do this?
Asked
Active
Viewed 42 times
-9
-
https://docs.python.org/2/reference/compound_stmts.html#for – Mohammed Aouf Zouag Jan 31 '16 at 15:00
-
Also see http://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response for techniques to ensure that the user input is valid. – PM 2Ring Jan 31 '16 at 15:06
1 Answers
0
Use a list and a while
loop.
data=[]
for x in xrange(100):
data.append(raw_input("Your data: "))
If you don't need to store the data that was entered, get rid of the list and process this data right in the loop.

ForceBru
- 43,482
- 10
- 63
- 98