Question1 = input("We will start off simple, what is your name?")
if len(Question1) > 0 and Question1.isalpha(): #checks if the user input contains characters and is in the alphabet, not numbers.
Question2 = input("Ah! Lovely name, %s. Not surprised you get all the women, or is it men?" % Question1)
if Question2.lower() in m: #checks if the user input is in the variable m
print ("So, your name is %s and you enjoy the pleasure of %s! I bet you didnt see that coming." % (Question1, Question2))
elif Question2.lower() in w: # checks if the user input is in the variable w
print ("So, your name is %s and you enjoy the pleasure of %s! I bet you didnt see that coming." % (Question1, Question2))
else: #if neither of the statements are true (incorrect answer)
print ("Come on! You're helpless. I asked you a simple question with 2 very destinctive answers. Restart!")
else:
print ("Come on, enter your accurate information before proceeding! Restart me!") #if the first question is entered wrong (not a name)
Question3 = input("Now I know your name and what gender attracts you. One more question and I will know everything about you... Shall we continue?")
複雑ではない、私はそれを実行したとき、私は最初に何が起こるかを教えてくれます: はいくつかのシナリオがありますが、私は2ときを説明します私は最初に私の名前が何であるか尋ねられたプログラムを実行する、私はアルファベットであるここに何かを入力することができる、それから私は男性や女性が好きかどうか私に尋ねる、私が知っている奇妙な私はそれが私が取り組んでいるプロジェクトです'男性'または '女性'のプログラムは完璧に動くが、もし私が言うと...「犬」と言うと、それはelseステートメントprint ("Come on! You're helpless. I asked you a simple question with 2 very destinctive answers. Restart!")
に従うだろうが、コードを続けて上の最後の行に行く。あなたの名前とどのような性別があなたを魅了して......。 私がしようとしているのは、「男性」または「女性」以外のものを入力する場合はスクリプトを再起動することです。 私はしばらくの声明がうまくいくと言われましたが、なぜ、どのように説明する必要がありますか?私はある意味ではPythonを初めて使い慣れました。再起動のPythonプログラム内とif文 - 正しい答えを得るために
正しい答えが与えられたらループを終了してループを終了します – Li357