Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this code adds 1. 2. 3. as the user inputs carry on e.g. 1. pepperoni 2.peppers 3. onions But I don't want it to count

this code adds 1. 2. 3. as the user inputs carry on

e.g.

1. pepperoni

2.peppers

3. onions

But I don't want it to count invalid inputs

e.g

1 . pepperoni

2. peppers

3. onioona

4. onions

instead, i want it to output

1. pepperoni

2. peppers

3. onioona

3. onions

toppingCount = 0

while True: #While loop that asks user for an input, ends when user types 'done'

toppingCount = toppingCount + 1 toppings = input(f"{toppingCount}. ") #Asks for user input, for toppoings toppings = toppings.lower() #This function turns the user input into lowercase letters total = total + 1 #everytime user enters something 'total' inceases by 1, keeping track of the number of times the user enters something total = int(total) #turing total into an interger

if (toppings != "pepperoni") and (toppings != "mushrooms") and (toppings != "onions") and (toppings != "peppers") and (toppings != "olives") and (toppings != "bacon") and (toppings != "sausage") and (toppings != "pineapple") and (toppings != "extra cheese") and (toppings != "done"): incorrect = incorrect + 1 #If user enters incorrect topping this will add 1 to the 'incorrect' varibale print(f"Sorry, {toppings} is not availible topping at Pipper Pizza") elif toppings == "done": incorrect = incorrect +1 break #If user types 'done' this will add 1 to the 'incorrect' variable, and break the loop so the program can move forward else: alltoppings += toppings+" " #This will add all the CORRECT user input into one variable called 'alltoppings' (as a string)image text in transcribed

while True: #While loop that asks user for an input, ends when user types 'done' toppingCount = toppingCount + 1 toppings = input(f"{topping Count}. ") #Asks for user input, for toppoings toppings = toppings. lower() #This function turns the user input into lowercase letters total = total + 1 #everytime user enters something 'total' inceases by 1, keeping track of the number of times the user enters something total = int(total) #turing total into an interger if (toppings != "pepperoni") and (toppings != "mushrooms") and (toppings != "onions") and (toppings != "peppers") and (toppings != "olives") and (toppings != "bacon") and (toppings != "sausage") and incorrect = incorrect + 1 #If user enters incorrect topping this will add 1 to the 'incorrect' varibale print(f"Sorry, {toppings} is not availible topping at Pipper Pizza") elif toppings == "done": incorrect = incorrect +1 break #If user types 'done' this will add 1 to the 'incorrect' variable, and break the loop so the program can move forward else: alltoppings += toppings+" " #This will add all the CORRECT user input into one variable called 'alltoppings' (as a string) while True: #While loop that asks user for an input, ends when user types 'done' toppingCount = toppingCount + 1 toppings = input(f"{topping Count}. ") #Asks for user input, for toppoings toppings = toppings. lower() #This function turns the user input into lowercase letters total = total + 1 #everytime user enters something 'total' inceases by 1, keeping track of the number of times the user enters something total = int(total) #turing total into an interger if (toppings != "pepperoni") and (toppings != "mushrooms") and (toppings != "onions") and (toppings != "peppers") and (toppings != "olives") and (toppings != "bacon") and (toppings != "sausage") and incorrect = incorrect + 1 #If user enters incorrect topping this will add 1 to the 'incorrect' varibale print(f"Sorry, {toppings} is not availible topping at Pipper Pizza") elif toppings == "done": incorrect = incorrect +1 break #If user types 'done' this will add 1 to the 'incorrect' variable, and break the loop so the program can move forward else: alltoppings += toppings+" " #This will add all the CORRECT user input into one variable called 'alltoppings' (as a string)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

2. Are my sources up to date?

Answered: 1 week ago