Video: Ways Of Styling Texts In Programming

Styling texts in programming


In my previous video, I have talked about how to add text in programming . In this video, I want to talk about styling text in programming. Follow me as we will look at that in this article.


Styling texts in programming

We now have the ability to add text to other pieces of text. But what if we want to change or remove certain characters from a piece of text? For example, let’s say we want to prompt a user for their favorite drink and then print “(userName) wants a (drink).” In this example, if our user inputs “WATER,” our output will be “(userName) wants a WATER” which would be incorrect. How can we fix this?

We can use the to upper case block to switch the letter case of a piece of text.


But, if we add “water” as the value of the upper case block, it will be changed to “WATER”. This is the opposite of what we want. To change from “WATER” to “water”, we need to change the letter case to lower case. By opening the drop down menu, we can switch between the different letter cases.


Now, we can properly ensure that our user input’s drink is stylized to the right case, so let’s try it! Create two input prompts with the prompt for text with message block from previous modules. One should ask the user “What is your name?” and the other should ask “What is your favorite drink?” You should also create two variables, userName and myDrink, to store the inputs.

Once you’ve created the input prompts and variables, use the lower case block to fix the value of myDrink. Attach the input prompt for myDrink to the to lower case block and then attach both to the set variable to block in order to store it.


Additionally, we can use the title case option from the drop down menu to ensure that the user’s name is properly capitalized. Title case will capitalize only the first letter of each word in a piece of text. We can use this to only capitalize the first letter of our user’s name the same way we fixed the capitalization for myDrink. Now our output should have proper capitalizations.

However, there is still one potential issue with our user’s input. For both userName and myDrink, the user may input text with a large number of spaces before or after their input (eg. “     water     ”). To fix this, we can use the trim spaces block.


This block will allow us to get rid of excess spaces on either side of a piece of text. The drop down menu will allow us to switch between removing spaces from the left sideright side, or both sides.


For the purposes of cleaning up our user’s inputs, we should remove spaces from both sides of userName and myDrink. Add a trim spaces block in between the set variable and letter case blocks for both variables.

If we now use a print block and a create text with block, we can print out “(userName) wants a (drink).” with the proper capitalization and spacing, regardless of user error.


Now your take on this article…

I know you might agree with some of the points that I have raised in this article. You might not agree with some of the issues raised. Let me know your views about the topic discussed. We will appreciate it if you can drop your comment. Thanks in anticipation.



Become Part Of our Fan Base on Facebook. Click Here.

Follow Us on twitter. Click Here.

Download Our App. Click Here
Many Crypto. One place. Use Roqqu




About Adeniyi Salau 829 Articles
I am an IT enthusiast and a man of many parts. I am a Certified Digital Marketer, Project Manager and a Real Estate Consultant. I love writing because that's what keeps me going. I am running this blog to share what I know with others. I am also a Superlife Stem Cell Distributor. Our Stem Cell Products can cure many ailments.

Be the first to comment

Leave a Reply

Your email address will not be published.


CommentLuv badge