#Jocelyn Schulz #11/14/11 # Echo client program import socket HOST = 'localhost' # The remote host PORT = 50008 # The same port as used by the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) numplur = {1: "ones", 2: "twos", 3: "threes", 4: "fours", 5: "fives", 6: "sixes", 7: "sevens", 8: "eights", 9: "nines"} numsing = {1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "sixe", 7: "seven", 8: "eight", 9: "nine"} found = {1: 0, 2:0, 3: 0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0} # Change stuff starting here for i in range(1,10): togo = str(i) + " " s.send(togo*4) data = s.recv(1024) x = data.split(" ") found[i] = int(x[0]) if int(x[0]) == 1: amt = numsing[i] mod = "is" else: amt = numplur[i] mod = "are" print "There", mod, int(x[0]), amt #You're not using x[1] here because if you're always guessing four of the same number, there will never be a number in an incorrect position s.close() print found