Create a program that asks the user to guess the color.
import random
colors = ['red', 'grren', 'blue', 'gray', 'black', 'white', 'orange']
color = random.choice(colors)
print('I have chosen a color')
print('It may be ', end='')
for c in colors:
print(c, end=' ')
print()
guess = ''
count = 0
while guess != color:
print('Try to guess it', end=' ')
guess = input()
count += 1
if guess != color:
print('No, it is not')
else:
print('Yes, you are right)
print(f'You have guessed it in {count} times')
Comments
Leave a comment