Day 029 - Project 29 : Text Colour Subroutine

If you have any questions, comments or issues with this project please post them here!

Bringing print statements to life with COLOR!

https://replit.com/@JackAdem/Day-029-Project-29-Text-Colour-Subroutine?v=1

Day 29 of #Replit100DaysOfCode #100DaysOfCode.

1 Like

I’m really confused with the challenge today: https://replit.com/@wittphoonsiri/day29100-days#main.py

Here is what I did. Anyone help please?

def ColorSubroutine(word, color):
  if color == "red":
    print("\033[31m", word, "\033[0m", sep ="", end="")
  elif color == "cyan":
    print("\033[36m", word, "\033[0m", sep ="", end="")
  elif color == "light purple":
    print("\033[35m", word, "\033[0m", sep ="", end="")
  else:
    print("\033[33m", word, sep ="", end="")

word = input(("what is the word you want to print?:"))
color = input(("what color do you want the word to be?:"))

print("\033[0m","Super Subroutine", "With my program","\033[0m", "I will print the", word, " you want to print in the", color,"you want it to be.", end="", sep="")

ColorSubroutine(word, color)

Hey folks,
My code is running and working, I am just worried that I leveraged calling the calling_colors() subroutine and perhaps the activity wanted me to use more print statements with the sep =“” and end= “” but for some reason when I tried doing that it was not working properly. Is there a bug with using end=“” in replit or the more likely scenario… am I messing it up? TIA

def calling_colors(color, word): 
  if color == "red":
    print("\033[0;31m", word, sep="", end="")
  elif color == "green":
    print("\033[0;32m", word, sep="", end=" ")
  elif color == "blue": 
    print("\033[0;34m", word, sep="", end=" ")
  elif color == "white":
    print("\033[37m", word, sep="", end=" ")
  else:
    print("please select red, green, or blue. Be mindful of capitalization.")


def main(): 
  print("Super Subroutine")
  print("\n")
  print("With my", end=" ")
  calling_colors("green", "new program")
  calling_colors("white", "I can just call red ('and')")
  calling_colors("red", "and")
  calling_colors("white", " that word will appear in the color I set it to. ")
  print("\n")
  print("\nWith no", end=" ")
  calling_colors("blue", "weird gaps")
  print("\033[37m.", end=" ")
  print("\n")
  print("\nEpic.")


main()