Put some better comments in TextColors. Add some colors to the output of 027_function

This commit is contained in:
Junior 2024-06-03 20:18:25 -04:00
parent a921daa177
commit 59503067e6
2 changed files with 10 additions and 2 deletions

View File

@ -1,5 +1,7 @@
# A simple example of making a function
from Utils.TextColors import TextColors
# Functions are blocks of code that can be
# called/referenced from elsewhere in the code.
# This can be useful if we need to do some common
@ -13,6 +15,6 @@ def you_baby(name):
your_name = None
while your_name != "":
your_name = input("What is your first name (hit <Enter> to quit): ")
your_name = input(TextColors.BRIGHT_BLUE + "What is your first name (" + TextColors.DARK_GRAY + "hit <Enter> to quit" + TextColors.BRIGHT_BLUE + "): " + TextColors.RESET)
if your_name != "":
print("Your name is", you_baby(your_name))
print(TextColors.BRIGHT_YELLOW + "Your name is " + you_baby(your_name) + TextColors.RESET)

View File

@ -1,4 +1,10 @@
# This class is just a container for color names
# used when printing text to the console/terminal.
# To use: from Utils.TextColors import TextColors
class TextColors:
# These are all basically terminal control codes
# interpreted by most shells
BLACK = '\033[30m'
RED = '\033[31m'
GREEN = '\033[32m'