列印(“你好!\n”)
user_name = input("你叫什么名字?\n")
列印(“你好,” 用戶名 “\n”)
print("你好嗎?\n")
列印( 用戶名 “\n”)
好=“快樂”
好=“悲傷”
好=“自殺”
if good != "happy": print("thats aswesome," user_name "\n")
elif good == "sad": print("對不起,我是個僵尸網路," user_name "\n")
elif good == "suicide": print("1-800 ('國家自殺預防')" user_name "\n")
uj5u.com熱心網友回復:
您沒有收到提示,因為您沒有要求任何輸入,并且您可能希望為 if else 定義一個基本案例
print("hello!\n")
user_name = input("what is your name?\n")
print("hello, " user_name "\n")
mood = input("how are you doing? %s \n" % user_name)
if mood == "happy": print("thats aswesome," user_name "\n")
elif mood == "sad": print("Am sorry but am a botnet," user_name "\n")
elif mood == "suicide": print("1-800 ('national Suicide Prevention')" user_name "\n")
else: print("Sorry I don't understand it")
uj5u.com熱心網友回復:
我想這是解決它的眾多方法之一:
print("hello!\n")
user_name = input("what is your name?\n")
print("hello, " user_name "\n")
print("how are you doing, " user_name "?\n")
good = input(""" 1. happy
2. sad
3. suicide
""")
if good == "happy" or good == "1": print("thats aswesome, " user_name "\n")
elif good == "sad" or good == "2": print("I Am sorry but I am a bot, " user_name "\n")
elif good == "suicide" or good == "3": print("1-800 ('national Suicide Prevention') " user_name "\n")
結果:
hello!
what is your name?
Jack
hello, Jack
how are you doing, Jack?
1. happy
2. sad
3. suicide
2
I Am sorry but I am a bot, Jack
hello!
what is your name?
Jack
hello, Jack
how are you doing, Jack?
1. happy
2. sad
3. suicide
happy
thats aswesome, Jack
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/454039.html
