Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program: shirt order
#3
color = input("Choose color between white and blue: ")
size = input("Choose size: ")
available = False
while not available:
    if color == "white":
        if size == "M" or size == "L":
            print("available")
            available = True
           
        else:
            print("unavailable")
            break
    elif color == "blue":
        if size == "M" or size == "S":
            print("available")
            available = True
        else:
            print("unavailable")
            break
    else:
        print("Please choose the correct color!")
        break
I don't understand why Python tags don't work now.
Anyway, I have several questions regarding the code now.
1. this part
available = False
while not available:
"while not available" in this case means True since we have "available = False", right? I still don't understand why we need this in exactly this way? Can we do the opposite? Set available to True...

2. When adding some third color I first receive Choose size input. Is there any way to avoid this? To get "Please choose the correct color!" immediately if I, for example, type in green colour?
Reply


Messages In This Thread
Program: shirt order - by Truman - Jan-17-2018, 11:22 PM
RE: Program: shirt order - by Larz60+ - Jan-18-2018, 02:02 AM
RE: Program: shirt order - by Truman - Jan-18-2018, 10:18 PM
RE: Program: shirt order - by Larz60+ - Jan-18-2018, 10:47 PM
RE: Program: shirt order - by Truman - Jan-18-2018, 11:13 PM
RE: Program: shirt order - by Larz60+ - Jan-19-2018, 12:00 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020