Home > other >  hi how do get the user to responed back,printstatment but its not allowing me to responed back
hi how do get the user to responed back,printstatment but its not allowing me to responed back

Time:04-01

print("hello!\n")

user_name = input("what is your name?\n")

print("hello, " user_name "\n")

print("how are you doing?\n")

print( user_name "\n")

good = "happy"

good = "sad"

good = "suicide"

if good != "happy ": print("thats aswesome," user_name "\n")

elif good == "sad": print("Am sorry but am a botnet," user_name "\n")

elif good == "suicide": print("1-800 ('national Suicide Prevention')" user_name "\n")

CodePudding user response:

You are not getting a prompt back because you did not ask for any input, and you might want to define a base case for 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")

CodePudding user response:

I guess this is one of many ways to solve it:

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

Result:

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
  • Related