0

endprog = "start" while endprog != "exit":

para = int(input("Enter a number 1-9 -> "))

if para == 1:
    print(''' THE ORIGINATOR
1's are originals. Coming up with new ideas and executing them is
natural. Having things their own way is another trait that gets them as
being stubborn and arrogant. 1\'s are extremely honest and do well to
learn some diplomacy skills. They like to take the initiative and are
often leaders or bosses, as they like to be the best. Being
self-employed is definitely helpful for them. Lesson to learn: Others'
ideas might be just as good or better and to stay open minded.
Famous 1's: Tom Hanks, Robert Redford, Hulk Hogan, Carol Burnett, Wynona
Judd, Nancy Reagan, Raque l Welch.''')
elif para == 2:
    print('''" THE PEACEMAKER
2's are the born diplomats. They are aware of others' needs and moods
and often think of others before themselves. Naturally analytical and
very intuitive they don't like to be alone. Friendship and companionship
is very important and can lead them to be successful in life, but on the
other hand they'd rather be alone than in an uncomfortable relationship.
Being naturally shy they should learn to boost their self-esteem and
express themselves freely and seize the moment and not put things off.
Famous 2's: President Bill Clinton, Madonna, Whoopee Goldberg, Thomas
Edison, Wolfgang Amadeus Mozart."''')

this will ask for the number and i will put in the number but after it only asks for number over and over again

  • 3
    Please edit the question and format the code correctly :). It also looks like you're missing some code, as you have nothing after `elif parra == 3:` – TerryA Oct 10 '13 at 05:28
  • So is the problem that the while-loop never breaks after printing something? – TerryA Oct 10 '13 at 05:39
  • http://stackoverflow.com/questions/8114355/loop-until-a-specific-user-input – alexvassel Oct 10 '13 at 05:41
  • the whole code goes to number 9 with a different paragraph for each but the same concept, I deleted the elif statements, typed them back in the same as I had it before, and it magically worked...slightly frustrating lol. – user2865566 Oct 10 '13 at 05:44

1 Answers1

2

I suspect the problem is with your while loop - the if and elsif blocks are outside the ambit of your while loop.

After correcting for those if, elsif conditions, the following code works for me

endprog = "start" 

while endprog != "exit":

    para = int(input("Enter a number 1-9 -> "))

    if para == 1:
        print(''' THE ORIGINATOR
1's are originals. Coming up with new ideas and executing them is
natural. Having things their own way is another trait that gets them as
being stubborn and arrogant. 1\'s are extremely honest and do well to
learn some diplomacy skills. They like to take the initiative and are
often leaders or bosses, as they like to be the best. Being
self-employed is definitely helpful for them. Lesson to learn: Others'
ideas might be just as good or better and to stay open minded.
Famous 1's: Tom Hanks, Robert Redford, Hulk Hogan, Carol Burnett, Wynona
Judd, Nancy Reagan, Raque l Welch.''')
    elif para == 2:
        print('''" THE PEACEMAKER
2's are the born diplomats. They are aware of others' needs and moods
and often think of others before themselves. Naturally analytical and
very intuitive they don't like to be alone. Friendship and companionship
is very important and can lead them to be successful in life, but on the
other hand they'd rather be alone than in an uncomfortable relationship.
Being naturally shy they should learn to boost their self-esteem and
express themselves freely and seize the moment and not put things off.
Famous 2's: President Bill Clinton, Madonna, Whoopee Goldberg, Thomas
Edison, Wolfgang Amadeus Mozart."''')
Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
  • 1
    This does not answer the question. All you did is repeat the user's code and say "I suspect the problem is with your while loop" – TerryA Oct 10 '13 at 05:44
  • @Haidro I took a guess that the user has incorrectly formatted his code. If you read the line `this will ask for the number and i will put in the number but after it only asks for number over and over again`, it means he was only entering the number, there was no output which meant the while loop had some issues. – Anshul Goyal Oct 10 '13 at 05:47
  • 1
    Yes, *what issues*? And *how do you fix these issues*? – TerryA Oct 10 '13 at 05:49
  • @Haidro The guess was that the `if` and `elsif` conditions are outside of the while loop, and that was the issue with his code :) Check this first line `endprog = "start" while endprog != "exit": para = int(input("Enter a number 1-9 -> "))` Fixing those issues meant reformatting the code so that the `if elsif` conditions are within the while loop. As I said earlier, I guessed it from this line of his `this will ask for the number and i will put in the number but after it only asks for number over and over again` – Anshul Goyal Oct 10 '13 at 05:52
  • Okay, that could be a formatting issue with the question, but be sure to edit your answer to reflect this – TerryA Oct 10 '13 at 05:53
  • @Haidro Have edited it. It was clear to me, It was somewhat clear to the OP, but I agree it wouldn't be clear to any other person.`Thanks – Anshul Goyal Oct 10 '13 at 05:59