Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Dialogues by ssk8
VOWELS = "aeiou"
class Chat:
def __init__(self):
self.dialogue = []
def connect_human(self, human):
human.connect = self.dialogue
def connect_robot(self, robot):
robot.connect = self.dialogue
def show_human_dialogue(self):
return '\n'.join([f'{x[0]} said: {x[1]}' for x in self.dialogue])
def show_robot_dialogue(self):
return '\n'.join([f'{x[0]} said: {"".join([("1","0")[c.lower() in VOWELS] for c in x[1]])}' for x in self.dialogue])
class Human:
def __init__(self, name):
self.name = name
def send(self, msg):
self.connect.append((self.name, msg))
class Robot:
def __init__(self, name):
self.name = name
def send(self, msg):
self.connect.append((self.name, msg))
July 12, 2018
Comments: