Today, I played around with something super simple but kinda fun – making a little echo robot. Basically, you type something in, and it repeats it back. I thought it would be a good way to mess with basic input and output.
Getting Started
First, I opened up my code editor. Nothing fancy, just a place to write and run the code. I decided to use Python because It’s pretty straightforward for this kind of thing.
I started by writing a line that would ask me for some input. Just one of these functions that displays message and take data:
- input()
Then I stored that in a variable using a suitable name, something like “user_input”. Easy peasy.
Making it Echo
Now for the repeating part. I wanted the program to print back whatever I typed. I can do this easily using print() function.
I just printed that user_input variable I’d saved earlier. So, if I typed “Hello”, the program would spit “Hello” right back at me.
Running the Thing
With the code written, I hit the run button. My terminal popped up, asking for input. I typed in a few different things, just to test it out:
- “Testing, testing…”
- “Is this thing on?”
- “12345”
And yep, every time, it echoed back exactly what I typed. Worked like a charm!
The final Result
It all worked! It’s such a tiny thing, but you feel like, “Hey, I made this!” I am going to share this experience, maybe someone will like it.