number game in python

This is not done,  But it is working.... Unless you give it bad input.
I don't have a lot of those errors worked out yet. 
I want a way to compare the answers given to ones already given, but It mucks up the code when I include it. 

Really thought translating the one I did in JAVA to python would be easier.... It's not.
Have to move on,  come back to this later.

import random

def guess_my_number():
start = print("Guess my number! range = 0-100. ")
print(('.')*15)
cpu_number = random.randint(0,100)
print(f" computers number = {cpu_number}.")
guesses = []
count = 1
if check_for_yes("play?"):
first_guess = int(input("First guess....:"))
if first_guess != cpu_number:
guesses.append(first_guess)
count += 1
stopper = True
elif first_guess == cpu_number:
print("Holy crap. Are you psychic?")
stopper = False
else: stopper = False

your_guess = int(input("Next guess....:"))

while stopper:
#if look_for_equals(guesses, your_guess):
#print(count)
#print(f"you already guessed the number: {your_guess}")
#your_guess = int(input("try again ..."))

if count == 10:
print(f"Sorry, my number was {cpu_number}")
stopper = False

elif your_guess == cpu_number:
print(f"You win! You got the answer in {count} trys!")
stopper = False
elif your_guess > cpu_number: #and your_guess != cpu_number:
your_guess = int(input("Your guess is too high. Try again."))
guesses.append(your_guess)
count += 1
elif your_guess < cpu_number: #and your_guess != cpu_number:
your_guess = int(input("Your number is too low. Try again."))
count +=1
guesses.append(your_guess)
else:
print("Error.")


def check_for_yes(playing):
playing = input("Do you want to play? yes, no, quit.")
if playing.lower() in ['yes', 'y']:
return True
elif playing.lower() in ['quit', 'q', 'no', 'n']:
print("Bored already? Later!.")
return False
else:
print("Else is executing")
exit()

def look_for_equals(somelist, arg):
if arg in somelist:
return True
else:
return False

guess_my_number()

Comments

Popular posts from this blog

playing with color in powershell python

JavaScript Ascii animation with while loops and console.log

playing with trigonometry sin in pygame