I am learning Python and while working on a simple while loop I get a syntax error but cannot figure out why. Below is my code and the error I get
products = ['Product 1', 'Product 2', 'Product 3']
quote_items = []
quote = input("What services are you interesting in? (Press X to quit)")
while (quote.upper() != 'X'):
product_found = products.get(quote)
if product_found:
quote_items.append(quote)
else:
print("No such product")
quote = input("Anything Else?")
print(quote_items)
I am using NetBeans 8.1 to run these. Below is the error I see after I type in Product 1:
What servese are you interesting in? (Press X to quit)Product 1
Traceback (most recent call last):
File "\\NetBeansProjects\\while_loop.py", line 3, in <module>
quote = input("What services are you interesting in? (Press X to quit)")
File "<string>", line 1
Product 1
SyntaxError: no viable alternative at input '1'
getmethod:products.get(quote)will raise an errorimport syssys.version