<commit_before>"""
sources: http://stackoverflow.com/questions/306400/how-do-i-randomly-select-an-item-from-a-list-using-python, https://inventwithpython.com/chapter9.html, http://stackoverflow.com/questions/14667578/check-if-a-number-already-exist-in-a-list-in-python, <NAME>, <NAME> (game tester), http://stackoverflow.com/questions/7522533/how-can-i-turn-a-string-into-a-list-in-python, http://www.tutorialspoint.com/python/list_remove.htm
"""
import time
import random
import string
a=string.ascii_lowercase
choose=int(input("Type '1' if you want to guess the word. Type '2' if you want the computer to guess your word. "))

if choose==2:
    newword=input("What is your word? ")
    newword=newword.lower()
    l=len(newword) #count the number of letters
    
    a2=list(a)
    letter=[]
    word=[] #creating a list of letters in newword
    for x in range(0,l):
        abc=newword[x]
        word.append(abc)
        
    letter1="e"
    letter.append(letter1)
    
    guess=[]
    turns=0
    num=0
        
    while num<1:
        for x in range(0,l):
            if letter1==word[x]:
                guess.append(letter1)
            else:
               guess.append('_')
        if letter1 not in word:
            turns=turns+1
        num=num+2
        print("Computer's guess = "+letter1+"   "+' '.join(guess) )
       
    

    while turns<7 and num>0:
        for x in a2:
            if x in letter:
                a2.remove(x)
        
        letter1=random.choice(a2)
        
        for x in range(0,l):
            if letter1==word[x]:
               guess[x]=letter1
            elif guess[x] not in a:
                guess[x]='_'
        
        if letter1 not in word:
            turns=turns+1
        print("Computer's guess = "+letter1+"   "+' '.join(guess) )
        
        #time.sleep(1)
        
        if turns==7:
            print("You stumped the computer!")
        
        if word==guess:
            print("The computer guessed your word.")
            turns=100

elif choose==1:
    words = ['giraffe', 'hangman', 'tulip', 'purple', 'petunia', 'delivery', 'extraneous', 'plywood', 'highway', 'pullover']
        
    newword=random.choice(words) #randomly select word
    l=len(newword) #count the number of letters
    
    word=[] #creating a list of letters in newword
    for x in range(0,l):
        abc=newword[x]
        word.append(abc)
        
    letter1=input("number of spaces = "+str(l)+". After seven wrong guesses, you lose. First guess? ") #first letter guess
    while letter1 not in a:
        letter1=input("Invalid input. Please guess a lowercase letter.") 
        
    guess=[]
    turns=0
    num=0
        
    while num<1:
        for x in range(0,l):
            if letter1==word[x]:
                guess.append(letter1)
            else:
               guess.append('_')
        if letter1 not in word:
            turns=turns+1
        num=num+2

    while turns<7 and num>0:<commit_msg>Updated from Brython Server: 4/29/2016 2:34:48 PM<commit_after>"""
sources: http://stackoverflow.com/questions/306400/how-do-i-randomly-select-an-item-from-a-list-using-python, https://inventwithpython.com/chapter9.html, http://stackoverflow.com/questions/14667578/check-if-a-number-already-exist-in-a-list-in-python, <NAME>, <NAME> (game tester), http://stackoverflow.com/questions/7522533/how-can-i-turn-a-string-into-a-list-in-python, http://www.tutorialspoint.com/python/list_remove.htm
"""
import time
import random
import string
a=string.ascii_lowercase
choose=input("Type '1' if you want to guess the word. Type '2' if you want the computer to guess your word. ")

if choose=='2':
    newword=input("What is your word? ")
    newword=newword.lower()
    l=len(newword) #count the number of letters
    
    a2=list(a)
    letter=[]
    word=[] #creating a list of letters in newword
    for x in range(0,l):
        abc=newword[x]
        word.append(abc)
        
    letter1="e"
    letter.append(letter1)
    
    guess=[]
    turns=0
    num=0
        
    while num<1:
        for x in range(0,l):
            if letter1==word[x]:
                guess.append(letter1)
            else:
               guess.append('_')
        if letter1 not in word:
            turns=turns+1
        num=num+2
        print("Computer's guess = "+letter1+"   "+' '.join(guess) )
       
    

    while turns<7 and num>0:
        for x in a2:
            if x in letter:
                a2.remove(x)
        
        letter1=random.choice(a2)
        
        for x in range(0,l):
            if letter1==word[x]:
               guess[x]=letter1
            elif guess[x] not in a:
                guess[x]='_'
        
        if letter1 not in word:
            turns=turns+1
        print("Computer's guess = "+letter1+"   "+' '.join(guess) )
        
        #time.sleep(1)
        
        if turns==7:
            print("You stumped the computer!")
        
        if word==guess:
            print("The computer guessed your word.")
            turns=100

elif choose=='1':
    words = ['giraffe', 'hangman', 'tulip', 'purple', 'petunia', 'delivery', 'extraneous', 'plywood', 'highway', 'pullover']
        
    newword=random.choice(words) #randomly select word
    l=len(newword) #count the number of letters
    
    word=[] #creating a list of letters in newword
    for x in range(0,l):
        abc=newword[x]
        word.append(abc)
        
    letter1=input("number of spaces = "+str(l)+". After seven wrong guesses, you lose. First guess? ") #first letter guess
    while letter1 not in a:
        letter1=input("Invalid input. Please guess a lowercase letter.") 
        
    guess=[]
    turns=0
    num=0
        
    while num<1:
        for x in range(0,l):
            if letter1==word[x]:
                guess.append(letter1)
            else:
               guess.append('_')
        if letter1 not in word:
            turns=turns+1
        num=num+2

    while turns<7 and num>0:
{'fraction_non_alphanumeric': 0.12836820083682007, 'fraction_numerical': 0.026108786610878662, 'mean_word_length': 1.9657568238213399, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '386332', 'n_tokens_mistral': 1996, 'n_tokens_neox': 1963, 'n_words': 475}