1

I have this code

import sys
#Jordan Run Game
class Character():

  def __init__(self, role):
    print "\033[91m Warrior \033[96m Mage"
    charRole = raw_input()

    if charRole == "Warrior":
      self.role = "Warrior"
    elif charRole == "Mage":
      self.role = "Mage"
    elif charRole == "Rouge":
      self.role = "Rouge"
    elif charRole == "Healer":
      self.role = "Healer"
    else:
      sys.exit()

    print "You chose %s" % self.role

character = Character(role = "")

The colors change, but for some reason every color changes.

For example, Mage is in blue, and so is every text after that.

enter image description here

DavidG
  • 24,279
  • 14
  • 89
  • 82
  • 1
    The ANSI escape sequences only tell where to *start* to color. There exist escapes that tell the terminal to go back to the default colour. In any case there are some modules that can automate this for you so that you don't have to deal with escape sequences at all.. – Bakuriu Nov 02 '16 at 16:05
  • See http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python – Dan D. Nov 02 '16 at 16:12

1 Answers1

1

You need to terminate the color

'\033[0m'

so you want

 print "\033[91m Warrior \033[96m Mage\033[0m"
bravosierra99
  • 1,331
  • 11
  • 23