Interact with user when they key in

Hi everyone.

I’m new with python… I have made a program for auto answer each user input into the window as below.

But my code has problem… when user input wrongly information, it has shown a message but when user input again… it not show anything.

Pls check and support me this sample.

Thanks you so much!

flag=True
print(“Welcome to auto answer… pls chose number code as below”)
print(" ")
print(“1. Excel”)
print(“2. Print”)
print(“3. Exit”)
while(flag==True):
user_response = input()
user_response=user_response.lower()
if(user_response == ‘1’):
print(“Me: Pls write your issue”)
if ‘excel’ in input() and ‘cham’ in input():
print(“Me: Pls wait”)
else:
print(“Me: Pls write more detail your issue”)

By default, the terminal would echo whatever the user types to the terminal, and input cannot override that. One simple workaround would be to use getpass instead. (Note: does not work in IDLE.)

1 Like

Since this site supports markdown, code examples can be represented using code blocks:
```python

```

I would recommend using them for any examples or future questions, it makes the code significantly easier to read:

flag = True
print(“Welcome to auto answer… pls chose number code as below”)
print(" ")
print(“1. Excel”)
print(“2. Print”)
print(“3. Exit”)
while(flag==True):
    user_response = input()
    user_response=user_response.lower()
    if(user_response == ‘1’):
        print(“Me: Pls write your issue”)
    if ‘excel’ in input() and ‘cham’ in input():
        print(“Me: Pls wait”)
    else:
        print(“Me: Pls write more detail your issue”)

That goes for indentation as well. It’s usually easier to write the code in a separate editor and then paste it into the code blocks.

What do you mean by “wrongly”? What message? One of the ones you have listed, or an exception with a traceback? Could you give us an example of what is happening that you think is wrong, for example copying and pasting the program’s input and output?