I am trying to make a simple script to output a random color and i want the user to choose how many random colors they want but it produces infinite colors. I have only started python and it would be very appreciated if someone could help me even though it is an indentation problem. Here is the code:
import random
g = 0
a = input("How many random colors would you like? ")
if not a.isdigit():
print("Please enter a number next time")
quit()
while True:
lister = "Purple", "Green", "Blue", "Red", "Orange", "Lime", "Yellow", "White", "Black", "Maroon", "Aqua", "Pink", "Teal", "Grey", "Gold", "Silver", "Bronze", "Fuchsia", "Magenta", "Violet", "Beige", "Indigo"
z = random.choice(lister)
print("Your color is: " + str(z))
g += 1
if g == a:
break
else:
continue
Aucun commentaire:
Enregistrer un commentaire