Hi,
I am trying to change some code from the following :
I am trying to change some code from the following :
# pizza def pizza(): print("What toppings would you like on your pizza? All pizzas have cheese. ") print("Enter X when you have finished adding toppings. ") toppings = "" next_topping = "" while next_topping != "X": print("So far you have a pizza with cheese " + toppings) next_topping = input("Enter topping ... ") toppings = toppings + " and " + next_topping print("Add your next topping (X when finished)") print("Your pizza will have cheese " + toppings + ". Enjoy! ") pizza()to a code which removes the 'and X' if the user enters X to end the while loop. I have tried the following code but I am stuck on why this gives an error :
# pizza def pizza(): print("What toppings would you like on your pizza? All pizzas have cheese. ") print("Enter X when you have finished adding toppings. ") toppings = "" next_topping = "" while next_topping != "X": print("So far you have a pizza with cheese " + toppings) next_topping = input("Enter topping ... ") if next_topping = "X": toppings = toppings else: toppings = toppings + " and " + next_topping[/b] print("Add your next topping (X when finished)") print("Your pizza will have cheese " + toppings + ". Enjoy! ") pizza()##My thinking here is if the user enters X then the toppings will just remain as toppings minus the X and if it doesnt include X then the toppings will be added as usual