Hello everyone, can someone help me figure out why my code runs in Python but won’t run in Moodle. I think my code might be missing something that Moodle needs but Python doesn’t.
This is the question:
You are writing a program that will be incorporated into a car dealership’s web page. You don’t have to worry about the details of the web page, you just need to construct and test the basic program logic.
Ask the user for their preferred car colour, as follows:
Preferred Colour: blue
The text in bold is to be the prompt. The text in red is a sample input.
Write a program that can distinguish between the following conditions:
*** blue: “We have a lovely Metallic Cobalt this year!”**
*** red: “This Candy-Apple Red says where I go, I go fast!”**
*** green: “This Granny Smith Green just screams power!”**
Otherwise, say “That’s a colour we don’t have on the lot, but we can order it for you as a custom job for just 5% more!”
This is my code:
lemons = str(input("Preferred Colour: ")) if lemons == "blue": print("We have a lovely Metallic Cobalt this year!") elif lemons == "red": print("This Candy-Apple Red says where I go, I go fast!") elif lemons == "green": print("This Granny Smith Green just screams power!") else: print("That's a colour we don't have on the lot, but we can order it for you as a custom job for just 5% more!")
Welcome to the Get Help category!
This is where you can ask questions about your code. Some important things to remember when posting in this category
- Learn how to ask a good question and get a good answer!
- Remember to include a link to the exercise you need help with!
- If someone answers your question, please mark their response as a solution
- Once you understand a new concept, come back and try to help someone else!