RexyBadDog

campus.gov.il - self.py course

Dec 7th, 2021 (edited)
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. # for the ASCII art i will use the Art library
  2. # in order to use it I ran this in a CMD windows console: 'pip install art'
  3. # doc: https://pypi.org/project/art/
  4. from art import *
  5.  
  6. # useful URL: https://s3.eu-west-1.amazonaws.com/data.cyber.org.il/virtual_courses/python/rolling_assignment/resources/hangman_welcome_screen.txt
  7. # useful URL: https://s3.eu-west-1.amazonaws.com/data.cyber.org.il/virtual_courses/python/rolling_assignment/resources/hangman.txt
  8.  
  9. # to clean the python console window:
  10. import os
  11. clear = lambda: os.system('cls')
  12. clear()
  13.  
  14. # for randomizing the player number of choices i will use the Random library
  15. import random
  16. numOfTries = random.randint(5,10)
  17. print("Welcome to the game Hangman\n",text2art("Hangman"), numOfTries)
  18.  
  19. import re # using regex expression to get the 7 states of the hangman game.
  20. import urllib.request  # the lib that handles the url stuff
  21. url = "https://s3.eu-west-1.amazonaws.com/data.cyber.org.il/virtual_courses/python/rolling_assignment/resources/hangman.txt"
  22. with urllib.request.urlopen(url) as response:
  23.    data = response.read().decode('utf-8')
  24. print(data)
  25. # gameState = re.findall(r"picture .*:", data)
  26. # print(type(gameState)," length is: ", len(gameState))
  27. gameState = re.split(r"picture .*:",data)
Add Comment
Please, Sign In to add comment