Record#
- Continue learning about string manipulation.
- Manipulating strings is equivalent to manipulating arrays, as strings can be seen as arrays.
- Today's exercise is to print the string entered by the user, using the entered string as a color code, such as r = red.
def color(t):
if t == "b":
print("\033[34m", end="")
elif t == "g":
print("\033[32m", end="")
elif t == "r":
print("\033[31m", end="")
elif t == "y":
print("\033[33m", end="")
elif t == " ":
print("\033[0m", end="")
mytxt = input("What sentence do you want rainbow-ising?\n")
for letter in mytxt:
color(letter.lower())
print(letter, end="")