I wrote a program that has a user input a word to produce a list of anagrams. How do I have it so that I can keep asking the user to input something until they input a blank line?
            Asked
            
        
        
            Active
            
        
            Viewed 1,472 times
        
    -10
            
            
        - 
                    5Use a loop, perhaps? – Greg Hewgill Mar 12 '15 at 19:03
- 
                    while true ask input , if input is bye then quit – taesu Mar 12 '15 at 19:03
- 
                    Simplest way to achieve this would be using loops. Otherwise, there some hard ways like calling/texting user asking him to enter inputs multiple times. – Heisenberg Mar 12 '15 at 19:05
- 
                    2You can literally google "python continuous user input" and find [this](http://stackoverflow.com/questions/5546761/python-continuously-prompting-for-user-input). Is google harder than asking here? – Sterling Archer Mar 12 '15 at 19:07
- 
                    Possible duplicate of [Asking the user for input until they give a valid response](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) – ruohola May 04 '19 at 14:20
1 Answers
0
            Try this:
while(True):
    x = raw_input("Enter something:")
    if x == "":
        break
Essentially, this will continue to ask the user Enter something: until the user enters nothing. If you want to parse the input into numbers, then you will need to have a try:...except:... in your code, or else it will break.
 
    
    
        Jason Cidras
        
- 509
- 5
- 11
- 
                    1Please don't cater to questions with no effort. We have standards here. – Sterling Archer Mar 12 '15 at 19:08
- 
                    2
- 
                    1Helping is fine, but helping on a question that a 5 second google search answers isn't what Stack Overflow is about. – Sterling Archer Mar 12 '15 at 19:39
- 
                    
