rebeccacc

forca/cliente

Jun 2nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import socket
  2. import sys
  3.  
  4. host = socket.gethostname()
  5. port = 9999
  6. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  7. s.connect((host, port))
  8.  
  9. acertou = False
  10. total_chutes = 1
  11.  
  12. r1 = s.recv(1024)
  13. r1 = r1.decode("ascii")
  14.  
  15. print("A palavra escolhida tem {} letras" .format(r1))
  16. while total_chutes<=3:
  17. print(total_chutes)
  18. chute = str(input("Diga uma letra: "))
  19. enviar = chute.encode("ascii")
  20. s.send(enviar)
  21.  
  22. rc = s.recv(1024)
  23. rc = rc.decode("ascii")
  24. print(rc)
  25. total_chutes +=1
  26. rc = s.recv(1024)
  27. rc = rc.decode("ascii")
  28. print(rc)
  29. k = str(input()).lower().encode("ascii")
  30. s.send(k)
  31.  
  32. rc2 = s.recv(1024)
  33. rc2 = rc2.decode("ascii")
  34. print(rc2)
  35. s.close()
  36. sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment