The objective of my task is to allow the user to enter a series of colours (maximum and minimum of 4, and have to be within 5 set colours). I'm supposed to write code that continuously prompts the user if what they've entered doesn't meet the criteria. And also enter a width and height between the numbers 2-8 (including 2 and 8). Am I able to use the & symbol when creating decision statements? I'm not sure if it is fact or not but I assumed it was a possibility due to the simultaneous assignment I set for variables :
I've tried everything I can, and I feel the key part I'm missing is membership checking what the user has entered to what "set colour list". My code is below:
def main(): colourslst = ["red", "green", "blue", "magenta", "cyan"] width, height = eval(input("Enter the width and height of patches: ")) while True: [B]if width & height > 8 and width & height < 2:[/B] width, height = eval(input("Enter the width and height of patches: ")) else: colour = input("Please enter the desired four colours: ") [B]if len(colour.split()) < 4 and colour.split() != colourslst:[/B] colour = input("Please enter the desired four colours: ") else: colourslst = colour.split() print(colourslst)
I know using if and else twice is an issue, however that is irrilevant right now as I am only interested in the part that's made bold at the moment until I solve the decision functions.