Just setting up my twttr
just setting up my twttr
— jack⚡️ (@jack) March 21, 2006
When texting or tweeting, it’s not uncommon to shorten words to save time or space, as by omitting vowels, much like Twitter (now knows as X) was originally called twttr. In a file called twttr.py
, implement a program that prompts the user for a str
of text and then outputs that same text but with all vowels (A, E, I, O, and U) omitted, whether inputted in uppercase or lowercase.
Hints
- Recall that a
str
comes with quite a few methods, per docs.python.org/3/library/stdtypes.html#string-methods. - Much like a
list
, astr
is “iterable,” which means you can iterate over each of its characters in a loop. For instance, ifs
is astr
, you could print each of its characters, one at a time, with code like:for c in s: print(c, end="")
Demo
Before You Begin
Log into cs50.dev, click on your terminal window, and execute cd
by itself. You should find that your terminal window’s prompt resembles the below:
$
Next execute
mkdir twttr
to make a folder called twttr
in your codespace.
Then execute
cd twttr
to change directories into that folder. You should now see your terminal prompt as twttr/ $
. You can now execute
code twttr.py
to make a file called twttr.py
where you’ll write your program.
How to Test
Here’s how to test your code manually:
- Run your program with
python twttr.py
. TypeTwitter
and press Enter. Your program should output:Twttr
- Run your program with
python twttr.py
. TypeWhat's your name?
and press Enter. Your program should output:Wht's yr nm?
- Run your program with
python twttr.py
. TypeCS50
and press Enter. Your program should outputCS50