1

Summary

I am making a program in python, and I've finished it, ran it in shell and it worked perfectly. However when I run the program in the Interactive Window, it produces an error while in the idle window, it doesn't.

Crash information

Picture of the error before the window crashes:

Error Before crash

### COFFEE SHOP APP ###
# IMPORTS
from Motto import ourMotto 
import time 
import os 
import sys 
# MAIN CODE
def CoffeeShopApp(): 
    # VARIABLES
    orderCost = 0 
    smallCost = 2.00 
    mediumCost = 3.50 
    largeCost = 4.75 
    spicyCost = 5.25 
    coffeeInput = False 
    sugarCost = 0.05 
    sugarInput = False 
    syrupCost = 0.50 
    syrupInput = False 
    print("Welcome to the Michael the Moose Coffee App - Where the price is right") 
    print("You've tried BartSucks, and it sucks so now try the best")
    print("We will guide you through the ordering process and our amazing Barista 'Michelle' in Barcelona will then serve you\n") 
    print("And our amazing Barista 'Michelle' in Barcelona will then serve you\n") 
    while coffeeInput == False:
        tempSize = input( 
        """
                    What size would you like your coffee?
        Small - 2€, Medium - 3.50€, Large - 4.75€  or Spicy - 5.25€
        """
        )
        tempSize = tempSize.title() 
        if tempSize == "Small": 
            coffeeSize = "Small" 
            coffeeInput = True 
            orderCost = (orderCost + smallCost) 
        elif tempSize == "Medium": 
            coffeeSize = "Medium" 
            coffeeInput = True 
            orderCost = (orderCost + mediumCost)
        elif tempSize == "Large":
            coffeeSize = "Large"
            coffeeInput = True 
            orderCost = (orderCost + largeCost)
        elif tempSize == "Spicy":
            coffeeSize = "Spicy"
            coffeeInput = True 
            orderCost = (orderCost + spicyCost)
        else:
            print("Please enter a valid size")
            coffeeInput = False
            time.sleep(0.5)

    print()
    orderCost = str(orderCost)
    print("Ok, currently your order costs "+orderCost+"€")
    time.sleep(0.5)
    print()

    while sugarInput == False:
        tempSugar = int(input(
        """
                How many sugars would you like added to your coffee?
        1 sugar - 0.05€, 2 sugars - 0.10€, 3 sugars - 0.15€, 4 sugars - 0.20€: 
        """
        ))
        if isinstance(tempSugar, int):
            if tempSugar > 4:
                print("Please enter a valid number of sugars")
                sugarInput = False
                time.sleep(0.5)
            else:
                orderCost = float(orderCost)
                orderCost = (orderCost + (tempSugar * sugarCost))
                sugarInput = True
        else:
            print("Please enter a number")

    print()
    orderCost=str(orderCost)
    print("Ok, currently your order costs "+orderCost+"€")
    time.sleep(0.5)
    print()

    while syrupInput == False:
        tempSyrup = input(
        """
                       Would you like syrup? (0.50€): 
        """)
        tempSyrup = tempSyrup.title()
        if tempSyrup == "Yes":
            syrupInput = True
        elif tempSyrup == "No":
            syrupInput = True
        else:
            print("Please enter either yes/no")
            time.sleep(0.5)

    orderCost = str(orderCost)
    print("Alright, your final order cost comes up to: "+orderCost+"€")
    name = input("Please enter your name and our barista Michelle will get straight to work on your coffee: ")
    name = name.upper()

    tempSugar = str(tempSugar)
    orderCost = str(orderCost)
    lines = ['Here is your new order: It is size: '+tempSize+'',
            'There are '+tempSugar+' sugars to be put in the coffee',
            'and they have said '+tempSyrup+' to having syrup.',
            'Their name is '+name+,
            'It will cost: '+orderCost+'€',
            '',
            '',
            '',
            '',
            '',
            '',
            '',
            ourMotto]
    with open('MichelleMooseCoffeeOrders.txt', 'w') as MMC:
        for l in lines:
            MMC.write(l + '\n')

    MMC.close()

    print(
    """
                           Your order has been proccessed
            Please come and collect your order at the shop within the hour,
                          or your order will be incinerated
    """
    )
    input("Press ENTER to exit the app")
    if mode == 'Interactive' or mode == 'I':
        os.system('cls')

mode = input("Are you in shell/interactive mode?")
mode = mode.title()
if mode == 'Interactive' or mode == 'I':
    os.system('cls')

input("Slide left to sign in")
if mode == 'Interactive' or mode == 'I':
    os.system('cls')

appreal = False
while appreal == False:
    app = input(
    """
                     What app would you like to use?
                Coffee Shop, (more coming sometime soon)
    """
    )
    app = app.title()
    if app == 'Coffee Shop' or app == 'Cs':
        if mode == 'Interactive' or mode == 'I':
            os.system('cls')
        CoffeeShopApp()
    elif app == '':
        pass

Line 169 is a call for a subroutine

Line 30 is an end of a print shaped like this:

print(
"""
*text here*
"""
)

And the line 12 seems to refer to a program in the python files. In the program it imports a variable from a python program in the same location as this question.

Related Files

The imported file is this:

ourMotto = ('You have been playing for over an hour. Please do not forget to take a break.')

It writes to a text file in the same file location named:

MichelleMooseCoffeeOrders

If you need me to add any more information about the program or help me format this question, then leave a comment. (I'm new to stack overflow and am still learning how to format questions so feedback helps)

error code after utf-8 encoding:

 Traceback (most recent call last):
    File"Z:\Year9\LessonWork\I.C.T\ComputerScience(Wednesday)\Programming\CoffeeShopApp\CoffeeShopApp.p, line 169, in <module>
      CoffeeShopApp
    File"Z:\Year9\LessonWork\I.C.T\ComputerScience(Wednesday)\Programming\CoffeeShopApp\CoffeeShopApp.py", line 30, in CoffeeShopApp
      """
  File "C:\Program Files (x86)\Python35-32\lib\encoding\cp850.py", line 12, in encode
    return codecs.charmaps_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character '\u20ac' in position 76:P character maps to <undefined>

0 Answers0