xxMagnum
xxMagnum

Reputation: 21

python code not being displayed on python 3.4.2 shell

print("hello")

def vendingMachine():

    count = 0
    totalCredit = 0
    coinNum = int(input("how many coins would you like to enter?:"))
    while count in range (coinNum):
         coin = float(input("enter coin: £"))
         totalCredit = totalCredit + coi
         count = count + 1
    print("you have £{0} in your bank.".format (round(totalCredit,2)))
    print("")
    print("choose your item:")
    print("")
    print("1.coca cola")
    print("2.lucozade")
    print("3.7up")
    print("4.fanta orange")
    print("5.pepsi")
    print("6.Diet pepsi")
    print("7.mountain dew")
    print("8.rubicon")
    print("9.Dr Pepper")
    print("10.sprite")
    print("")
    finalCredit = totalCredit
    round (finalCredit, 2)
    item = int(input("enter the number for your item:"))
    while item <1 or item >10:
        print("this item is not available.")
        item = int(input("enter the nuber for your item: "))
    if item == 1:
        finalCredit = totalCredit - 0.59
        print ("you now have a Coca cola can, costing £0.59.")
        print ("you have {0} remaining in your bank.".format (round(finalCredit,2)))

when i run it (f5) this comes up:

>>> ================================ RESTART ===============================
>>> 
hello
>>> 

how do i make it so the full code shows up not just 'hello' im using python IDLE 3.4.2 i copied this from a youtube video thanks

Upvotes: 0

Views: 48

Answers (2)

Yaoshicn
Yaoshicn

Reputation: 144

Because you did not call your function. Please add these code at the end of your python file. And then run your program again.

if __name__ == "__main__":
   vendingMachine()

Upvotes: 0

raddevus
raddevus

Reputation: 9077

Add a line that calls the function right after the code where you define the function.

vendingMachine()

Run again and it will run other code.

You've def(ined) the function but never called it.

Upvotes: 1

Related Questions