if 'BOUT' in buf and 'GOD' in buf !=-1: print "I am playing!" a='1' # PLAYER 1 if a=='1' and buf.find('JOINT 0;')!=-1: test = repr(buf) test = test.strip("'") test = test.replace("14", "15") test = test.replace("5", "4") test = test.replace("9", "8") test = test.replace("0", "1", 1) test = test.strip("\\n") s.send("GRIP 1;1 1\n %s\n" % test) else: print "Not playing!"