Python Forum
No output in shell? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: No output in shell? (/thread-10839.html)



No output in shell? - g_109 - Jun-09-2018

This is my first time posting in this forum so sorry in advance if i have done something wrong or not explained the problem clearly!

Hi,
so my python program to create a coffee ordering system was working great but has now suddenly stopped working. When I go to the shell and enter main() or define main () nothing happens. Literally no errors. nothing.

Here is the code:
# 10 TECH ASSIGNMENT
# Created by G_109 on 30/5/18


############################  START OF FUNCTIONS ###############################
def create_list():
    global menu
    menu = ["\nAHS COFFEE CART MENU"                         ] 
    menu.append("1.  Cafe Latte, Regular                  $") 
    menu.append("2.  Cafe Latte, Large                    $") 
    menu.append("3.  Cappuccino, Regular                  $") 
    menu.append("4.  Cappuccino, Large                    $")
    menu.append("5.  Espresso, Regular                    $")
    menu.append("6.  Espresso, Large                      $") 
    menu.append("7.  Americano, Regular                   $") 
    menu.append("8.  Americano, Large                     $") 
    menu.append("9.  Macchiato, Regular                   $") 
    menu.append("10. Macchiato, Large                     $") 
    menu.append("11. Caffe Mocha, Regular                 $")
    menu.append("12. Caffe Mocha, Large                   $") 
    menu.append("13. English Breakfast Tea, Regular       $") 
    menu.append("14. English Breakfast Tea, Large         $") 
    
    
    
    global menu_price
    menu_price = [""]
    menu_price.append(4.5)
    menu_price.append(5.0)
    menu_price.append(4.5)
    menu_price.append(5.1)
    menu_price.append(4.0)
    menu_price.append(4.8)
    menu_price.append(4.1)
    menu_price.append(4.8)
    menu_price.append(4.5)
    menu_price.append(5.0)
    menu_price.append(3.5)
    menu_price.append(4.5)
    menu_price.append(3.0)
    menu_price.append(4.0)
    menu_price.append("")
    newCustomer()

def newCustomer():
    global customerNum
    while customerNum < 100:
        customerNum + 1
    else:
        customerNum = 1
    global totalCost
    totalCost = 0
    print("Welcome to the All Hallows Coffee Cart")
    global customer_Name
    customer_Name = input("Please enter your name: ")
    customer_Name = customer_Name.capitalize()
    displayMenu()
          
def displayMenu ():
    num = 0
    for num in range(0, 15):
        print(menu[num], menu_price[num])
        num+=1
    print("Q.  Quit")
    print("")
    menu_order()
    
def menu_order():
    menu_order = input("Please enter the number of your drink order: ")

    if(menu_order == "Q")|(menu_order == "q"):
        quit()
    elif int(menu_order) in range (1, 14):
        menu_order = int(menu_order)
        extras_menu_sugar()
def extras_menu_sugar():
    sugar_amount = input("Sugars are $0.1 per tsp. Enter how many sugars you would like: ")
    if (sugar_amount == "1")|(sugar_amount == "2")|(sugar_amount == "3")|(sugar_amount == "4"):
        sugar_amount = int(sugar_amount)
        sugar_cost = (sugar_amount * 0.1)
        extras_menu_chocolate()
    elif (sugar_amount == "0"):
        extras_menu_chocolate()        
    else:
        print("Invalid order.")
        extra_menu_sugar()


def extras_menu_chocolate():
    chocolate_amount = input("Chocolate is $0.5 per tsp. Enter how much chocolate you would like: ")
    if (chocolate_amount == "1")|(chocolate_amount == "2")|(chocolate_amount == "3")|(chocolate_amount == "4"):
        chocolate_amount = int(chocolate_amount)
        chocolate_cost = (chocolate_amount * 0.5)
        lucky_number()
    elif (chocolate_amount == "0"):
        lucky_number()    
    else:
        print("Invalid order.")
        extra_menu_chocolate()

def lucky_number():
    import random
    lucky_number = (random.randint(0,100))
    if lucky_number == 30:
        set (totalCost == 0)
        print("Congratulations, you have recieved the lucky number for today! Enjoy your free order")
    else:
        print("Your lucky number was",lucky_number)
        print("You did not recieve the lucky number for today.")

def customer_reciept():
    print("")
    print("CUSTOMER RECEIPT")
    print("Your customer number is:",customerNum)
    print("Your menu order is",menu_order)
    print("Your extra cost for sugar is",extras_menu_sugar)
    print("Your extra cost for chocolate is",extras_menu_chocolate)
    print("Your total is",totalCost)
  


        
    
        
    
############################  END OF FUNCTIONS ###############################

# Functions are run in order to output the digital solution in the shell


def main():
    global customerNum
    customerNum = 0
    create_list()
    customer_reciept()
    print("Thankyou", customer_Name, "for purchasing from the AHS Coffee Cart. Hope to see you back again soon!")]
Here is the output in the shell:
https://imgur.com/a/1WLUrTE

(sorry if the link doesn't work, but it just basically shows how it jumps a line down from where i type "main()" and then the chevrons disappear!)


RE: URGENT PLEASE HELP - j.crater - Jun-09-2018

Well first things first. Don't put caps in thread name and prefereably use a meaningful title instead of "I need help" and so.
Second, put your code in Python code tags, you can find help here.


RE: No output in shell? - g_109 - Jun-09-2018

Thankyou! I have edited my post accordingly, this is my first post so I know nothing about the rules.

Any suggestion of what to do??


RE: No output in shell? - j.crater - Jun-09-2018

The rules may have been written when you registered or just before posting the thread, but that's fine, thanks for editing the post accordingly.

First, in last line (132), you have a trailing "]" which is no use.
In line 44 you have customerNum + 1, which won't do much because it doesn't store it to a variable.

The code then executes alright for me (gives welcome message and asks for name input). Although it's weird you didn't get any error messages.


RE: No output in shell? - buran - Jun-09-2018

(Jun-09-2018, 07:45 AM)j.crater Wrote: Although it's weird you didn't get any error messages.
it just go in endless loop (of course, after removing the extra ] you mention - maybe it did come when tags were added)


RE: No output in shell? - j.crater - Jun-09-2018

(Jun-09-2018, 07:51 AM)buran Wrote:
(Jun-09-2018, 07:45 AM)j.crater Wrote: Although it's weird you didn't get any error messages.
it just go in endless loop (of course, after removing the extra ] you mention)

At which point it does? Seems I missed that.


RE: No output in shell? - buran - Jun-09-2018

(Jun-09-2018, 07:52 AM)j.crater Wrote: At which point it does? Seems I missed that.
exactly at line 43-44 where you said. because they don't assign it, value always stays 0, so it doesn't exit the while loop


RE: No output in shell? - j.crater - Jun-09-2018

Oh geez, too obvious for me to notice it seems :D Good one.


RE: No output in shell? - g_109 - Jun-09-2018

Thankyou both for the help! I really appreciate it! :)