Guessing Game I created using rules from a post in this foru

This is the place to post any code that you want to share with the community. Only completed scripts should be posted here.
Note: posts here are not necessarily endorsed by the community, and may represent amateur or even bad practices.

Guessing Game I created using rules from a post in this foru

Postby Loophole_ » Thu Sep 01, 2016 8:58 pm

Code: Select all
from random import *

def DrawGen() :
    draw = ''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ') for num in range(3))
    return draw

def Checker(draw, guess) :
    if guess.upper() == draw : return 'Positive'
    else :
        hint = ''
        for count,digit in enumerate(guess) :
            if draw[count] == digit : hint += 'A'
            elif digit in draw : hint += 'C'
            else : hint += 'B'
    return hint 

Hint_A = 'A -- Indicates that value is the right value and it is in the right position'
Hint_B = 'B -- Indicates that It is the wrong value'
Hint_C = 'C -- Indicates that value is right but it is out of position'

draw = DrawGen()
guess = input('Enter Your Guess : >> ').upper()

while Checker(draw, guess) != 'Positive' :
    print('[HINT] :: > ' + str(Checker(draw, guess)))
    COUNT += 1
    guess = input('Enter Your Guess : >> ').upper()
else : print('You won in ' + str(COUNT) +' tries.')

All corrections and improvements are welcome!
Posts: 29
Joined: Tue May 24, 2016 4:58 pm

Return to Completed Scripts

Who is online

Users browsing this forum: No registered users and 2 guests