Ping-Pong
Ping or Pong¶
Write a program that reads the users’ input once. Depending on the input given, it should do different things:
Input | Reaction |
---|---|
ping |
Output pong |
pong |
Output ping |
empty string | Do nothing (No Output) |
anything else | Output That is not Ping-Pong |
Consider first what an empty string could mean and how you might check for it.
Hints
If you are unsure about the empty string try the following in the REPL:
Doing nothing turns out to be harder that it sounds. You have some options to approach this:
- Learn about the
pass
keywoard - Organize your conditions in a way, that the empty string case would end up in the
else
branch and leave that out. - Consider nesting two conditionals into each other with the outer one checking if whether the input is am empty string.
A whole Match¶
Put your code inside a loop to run it repeatedly.
The loop should end if the user inputs the word stop
.