Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # for the ASCII art i will use the Art library
- # in order to use it I ran this in a CMD windows console: 'pip install art'
- # doc: https://pypi.org/project/art/
- from art import *
- # useful URL: https://s3.eu-west-1.amazonaws.com/data.cyber.org.il/virtual_courses/python/rolling_assignment/resources/hangman_welcome_screen.txt
- # useful URL: https://s3.eu-west-1.amazonaws.com/data.cyber.org.il/virtual_courses/python/rolling_assignment/resources/hangman.txt
- # to clean the python console window:
- import os
- clear = lambda: os.system('cls')
- clear()
- # for randomizing the player number of choices i will use the Random library
- import random
- numOfTries = random.randint(5,10)
- print("Welcome to the game Hangman\n",text2art("Hangman"), numOfTries)
- import re # using regex expression to get the 7 states of the hangman game.
- import urllib.request # the lib that handles the url stuff
- url = "https://s3.eu-west-1.amazonaws.com/data.cyber.org.il/virtual_courses/python/rolling_assignment/resources/hangman.txt"
- with urllib.request.urlopen(url) as response:
- data = response.read().decode('utf-8')
- print(data)
- # gameState = re.findall(r"picture .*:", data)
- # print(type(gameState)," length is: ", len(gameState))
- gameState = re.split(r"picture .*:",data)
Add Comment
Please, Sign In to add comment