The following is an optimized version of your work which in-turn aims at more user-friendly experience.
I hope this would be helpful.
Happy Coding ;)
import time
colors = {
'bright green': '\x1b[1;32;40m',
'red' : '\x1b[1;31;40m',
'yellow' : '\x1b[1;33;40m',
'blue' : '\x1b[1;34;40m',
'purple' : '\x1b[1;35;40m',
'cyan' : '\x1b[1;36;40m',
'white' : '\x1b[1;37;40m',
'black' : '\x1b[1;30;40m'
}
for item in colors.keys():
print(colors.get(item), item);
while(True):
print(colors.get('white'), 'Please enter disired text color\n')
user_input = input().lower()
desiredColor = colors.get(user_input);
if(desiredColor is None):
print("Sorry! Desired color is unavailable\nPlease choose from the provided ones...\n")
continue
print(desiredColor, 'Great! You chose', user_input)
time.sleep(2)
print("Want to give another try? : ( Anything apart from 'NO' is considered to be 'YES' )")
if(input().lower()=='no'):
print("Thank you for your Time!")
break