Intro Bite 02. Infinite loop, input, continue and break
Login and get codingIn this Bite we'll get you to take user input using the
inputbuiltin and see if it matches items within a list.In the
whileloop ask the user to enter a color and capture that input.Check to see whether they've entered 'quit'. If so, print bye and exit (
break) the loop, effectively ending the function.If not, check to see whether the color (input) is in the
VALID_COLORScolor list. If it is, then print the color in lower case. If not, print Not a valid color andcontinuethe loop. Then conclude by printing bye.For this exercise the tests check standard output (what you print) so it's important to not print anything else (e.g. a string asking the user to enter a color), nor invoke the
print_colors()function at the bottom of your code. It will fail the tests.As you want to ask the user over and over again till they quit, you can use an infinite
whileloop. We already provided that in the template code, just code inside that loop.
5882 out of 6509 users completed this Bite.
Will you be the 5883rd person to crack this Bite?
Resolution time: ~28 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 4.07 on a 1-10 difficulty scale.
» Up for a challenge? 💪