What: color guessing game

Left to do:

  • Procedural abstraction
  • Managing complexity
  • Double check everything else

Win Example

import random

Colors = {1: 'Blue', 2: 'Red', 3: 'Green', 4:'Black', 5:'White'}
answer = Colors[random.randrange(1, 6)]
print("You have 4 tries to guess the color!")
print("Options:")
for keys, value in Colors.items():
   print(value)
print("-----------------------")
def guess():
    userGuess = input("What color do you think it is?")
    i = 0
    while i < 4:
        if userGuess == answer:
            print(f"You Win! The color was {answer}")
            break
        else:
            print(f"Wrong guess, its not {userGuess}")
            userGuess = input("Wrong, new guess?")
            i = i + 1
    if i == 4:
        print("Too many guesses you lose!")
guess()
You have 4 tries to guess the color!
Options:
Blue
Red
Green
Black
White
-----------------------
Wrong guess, its not Blue
Wrong guess, its not Red
You Win! The color was Green

Loss Example

import random

Colors = {1: 'Blue', 2: 'Red', 3: 'Green', 4:'Black', 5:'White'}
answer = Colors[random.randrange(1, 6)]
print("You have 4 tries to guess the color!")
print("Options:")
for keys, value in Colors.items():
   print(value)
print("-----------------------")
def guess():
    userGuess = input("What color do you think it is?")
    i = 0
    while i < 4:
        if userGuess == answer:
            print(f"You Win! The color was {answer}")
            break
        else:
            print(f"Wrong guess, its not {userGuess}")
            userGuess = input("Wrong, new guess?")
            i = i + 1
    if i == 4:
        print("Too many guesses you lose!")
guess()
You have 4 tries to guess the color!
Options:
Blue
Red
Green
Black
White
-----------------------
Wrong guess, its not Red
Wrong guess, its not Red
Wrong guess, its not Red
Wrong guess, its not Red
Too many guesses you lose!
import random


print("Choose 5 random colors!")
color1 = str(input("Color 1?"))
color2 = str(input("Color 2?"))
color3 = str(input("Color 3?"))
color4 = str(input("Color 4?"))
color5 = str(input("Color 5?"))

Colors = {1: color1, 2: color2, 3: color3, 4: color4, 5: color5}
answer = Colors[random.randrange(1, 6)]
print("You have 4 tries to guess the color!")
print("Options:")
for keys, value in Colors.items():
   print(value)
print("-----------------------")
def guess():
    userGuess = input("What color do you think it is?")
    i = 0
    while i < 4:
        if userGuess == answer:
            print(f"You Win! The color was {answer}")
            break
        else:
            print(f"Wrong guess, its not {userGuess}")
            userGuess = input("Wrong, new guess?")
            i = i + 1
    if i == 4:
        print("Too many guesses you lose!")
guess()
Choose 5 random colors!
You have 4 tries to guess the color!
Options:
Red
Blue
Green
Purple
Black
-----------------------
Wrong guess, its not Red
Wrong guess, its not Blue
You Win! The color was Black