Learn practical skills, build real-world projects, and advance your career
!pip install jovian --upgrade --quiet

Colors Choices Game (CCG) coding in python

(red, yellow, orange, green, blue)

import random

colors = ('red', 'orange', 'yellow', 'green', 'blue')
play = 'y'
player_score = 0
comp_score = 0

while play == 'y':
    color = input("Enter color: ")
    comp_choice = random.choice(colors)

    if color in colors:
        print("Good color choice.")
    else:
        print("Invalid Color choice. Game Closed.")
        break
    
    if comp_choice == color:
        print("The computer's choice is", comp_choice)
        print("You Won. Congratulations!")
        player_score += 1
    else:
        print("The computer's choice is", comp_choice)
        print("You lose :(")
        comp_score += 1
        
    print("Score \n Your =", player_score, "Computer =", comp_score,'\n')
    play  = input('Play again? (y/n): ')
    
    if play == 'y':
        pass
    else:
        goodbye(play)
Enter color: red Good color choice. The computer's choice is green You lose :( Score Your = 0 Computer = 1 Play again? (y/n): n Alright! See you soon.
def goodbye(play):
    if play == 'n':
        print('Alright! See you soon.')
    else:
        print('Invalid Entry. Game Closed.')
import jovian
jovian.commit(project = 'ccg-notebook')
[jovian] Attempting to save notebook..