dot
dot

Reputation: 1

My Code just doesn't work, how do I fix it?

Basicly I just made a Calculator Code (it should probably work) but is just shows the Ascii Art CALC but doesn't actually run the Calculator Code, no error or anything, just doesn't run a Part of Code for some Reason. -_- (The Ascii Art in the Code may look messy but actually its ok in the cmd)

import time
from colorama import init, Fore
init()

print(Fore.CYAN)
print("  _______     ____     ___          _______")
print(" /       |   /    \\   |   |        /       |")
print("|    ____/  /  /\\  \\  |   |       |    ____/")
print("|   |      |  /  \\  | |   |       |   |")
print("|   |      |  ¯¯¯¯  | |   |       |   |")
print("|   |      |   __   | |   |       |   |")
print("|    ¯¯¯¯\\ |  |  |  | |   ¯¯¯¯¯¯\\ |    ¯¯¯¯\\")
print(" \\       | |  |  |  | |         |  \\       | U L A T O R  //made by dot.")
print("  ¯¯¯¯¯¯¯   ¯¯    ¯¯   ¯¯¯¯¯¯¯¯¯    ¯¯¯¯¯¯¯")
print(Fore.WHITE)

def start():
    func = input("\n+ - * / : ")
    p = input("Math Problem: ")
    pl_ps = p.split(" + ")
    mi_ps = p.split(" - ")
    mu_ps = p.split(" * ")
    di_ps = p.split(" / ")
    if func == "+":
        one = int(pl_ps[0])
        two = int(pl_ps[1])
        answer = one + two
        print(answer)
    elif func == "-":
        one = int(mi_ps[0])
        two = int(mi_ps[1])
        answer = one - two
        print(answer)
    elif func == "\*":
        one = int(mu_ps[0])
        two = int(mu_ps[1])
        answer = one * two
        print(answer)
    else:
        if func == "/":
            one = int(di_ps[0])
            two = int(di_ps[1])
            answer = one / two
            print(answer)
        else:
            print("The option " + '"'+func+'"' + " does not exist.")
def e():
    exit = input("Restart(r),Exit(e): ")
    if exit == "r":
        start()
    else:
        if exit == "e":
            print("Closing Programm...")
            time.sleep(1)
        else:
            print("The option " + '"'+exit+'"' + " does not exist.")
            time.sleep(1)
            e()

Upvotes: 0

Views: 56

Answers (2)

ppwater
ppwater

Reputation: 2277

You never call your functions. They don't automatically run if they don't get called. So you can call it like yourfuncname().

import time
from colorama import init, Fore
init()

print(Fore.CYAN)
print("  _______     ____     ___          _______")
print(" /       |   /    \\   |   |        /       |")
print("|    ____/  /  /\\  \\  |   |       |    ____/")
print("|   |      |  /  \\  | |   |       |   |")
print("|   |      |  ¯¯¯¯  | |   |       |   |")
print("|   |      |   __   | |   |       |   |")
print("|    ¯¯¯¯\\ |  |  |  | |   ¯¯¯¯¯¯\\ |    ¯¯¯¯\\")
print(" \\       | |  |  |  | |         |  \\       | U L A T O R  //made by dot.")
print("  ¯¯¯¯¯¯¯   ¯¯    ¯¯   ¯¯¯¯¯¯¯¯¯    ¯¯¯¯¯¯¯")
print(Fore.WHITE)

def start():
    func = input("\n+ - * / : ")
    p = input("Math Problem: ")
    pl_ps = p.split(" + ")
    mi_ps = p.split(" - ")
    mu_ps = p.split(" * ")
    di_ps = p.split(" / ")
    if func == "+":
        one = int(pl_ps[0])
        two = int(pl_ps[1])
        answer = one + two
        print(answer)
    elif func == "-":
        one = int(mi_ps[0])
        two = int(mi_ps[1])
        answer = one - two
        print(answer)
    elif func == "\*":
        one = int(mu_ps[0])
        two = int(mu_ps[1])
        answer = one * two
        print(answer)
    else:
        if func == "/":
            one = int(di_ps[0])
            two = int(di_ps[1])
            answer = one / two
            print(answer)
        else:
            print("The option " + '"'+func+'"' + " does not exist.")
def e():
    exit = input("Restart(r),Exit(e): ")
    if exit == "r":
        start()
    else:
        if exit == "e":
            print("Closing Programm...")
            time.sleep(1)
        else:
            print("The option " + '"'+exit+'"' + " does not exist.")
            time.sleep(1)
            e()
if __name__ == "__main__":
    start()
    e()

Upvotes: 2

lollerskates
lollerskates

Reputation: 1147

how are you running your script? Is it being called by another script or are you running this script directly? If the latter, you never called start()

Upvotes: 0

Related Questions