Search code examples
pythonterminalruntime-errorbreakautopep8

break in running program in python


when i run this code in terminal** i should prees" enter " key to run after line 6 ** i dont know the problem i'm in the learning python proccess thank all of you in advance........

print("hi dear,\n welcom to my program in python")
name = input("please enter your name:")


def greeting(name):
    print(input(f"hello dear {name}"))


greeting(name)
question1 = print(input(f"how are you today dear {name}?"))
answer1 = "fine"
if answer1 == True:
    print("good to know that\nGood Luck my Friend")
else:
    print(input(q2="describe for me what happen to you??!!"))
    q2 = ""
    if q2 == True:
        print("ok,no problem...we can solve it.\nplease call to your best friend or doctor for get better.")
else:
    print("contact me on this account\[email protected]!!!")

Solution

  • Ok I am not sure what you mean by press enter as it doesn't seem that any of your prompts expect enter specifically. Anyway the problem is input doesn't take any arguments. Meaning input(q2="enter a value") is not vaild. It should be q2=inpt("enter a value"). And that leads us to one more problem. Here question1 = print(input(f"how are you today dear {name}?")) you are not saving the value returned from the user in question1, but using it in print and the return value from print is stored in question1 which is None. Try this line alone and print question1 to see what I mean. Now I believe there is still some logical error in your code because you write q2="" after the input so in this case the input will never be stored because you overwrite it.