0

endprog = “开始” 而 endprog ! = “退出”:

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."''')

这将询问号码,我将输入号码,但之后它只会一遍又一遍地询问号码

4

1 回答 1

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."''')
于 2013-10-10T05:40:55.840 回答