5 votes
495 views
in Technology by 🪄 Spell Caster (4.0k points)


# if anything has a red underline, its just KS being weird
while True:
    run = 0
    order = []
    script = 1

    while script == 1:
        imput = input("")
        order.append(imput)
        if imput == "run()":
            script = 0
            imput = 0
            run = 1
    while run == 1:
        # variables
        if order[0] == "set'":
            if order[1] == "1":
                var1 = order[2]
            elif order[1] == "2":
                var2 = order[2]
            elif order[1] == "3":
                var3 = order[2]
            order.pop(0)
            order.pop(0)
            order.pop(0)

        # print
        if order[0] == "write'":
            print(order[1])
            order.pop(0)
            order.pop(0)
        elif order[0] == "write":
            if order[1] == "1":
                print(var1)
            elif order[1] == "2":
                print(var2)
            elif order[1] == "3":
                print(var3)
            if order[1] == "result":
                print(int(solution))
            order.pop(0)
            order.pop(0)

        # math
        if order[0] == "add'" or order[0] == "subtract'" or order[0] == "multiply'" or order[0] == "divide'":
            if order[0] == "add'":
                solution = int(order[1]) + int(order[2])
            elif order[0] == "subtract'":
                solution = int(order[1]) - int(order[2])
            elif order[0] == "multiply'":
                solution = int(order[1]) * int(order[2])
            elif order[0] == "divide'":
                solution = int(order[1]) / int(order[2])
                order.pop(0)
                order.pop(0)
                order.pop(0)
        if order[0] == "add" or order[0] == "subtract" or order[0] == "multiply" or order[0] == "divide":
            if order[1] == "1":
                x = int(var1)
            elif order[1] == "2":
                x = int(var2)
            elif order[1] == "3":
                x = int(var3)
            if order[2] == "1":
                y = int(var1)
            elif order[2] == "2":
                y = int(var2)
            elif order[2] == "3":
                y = int(var3)
            if order[0] == "add":
                solution = x + y
            elif order[0] == "subtract":
                solution = x - y
            elif order[0] == "multiply":
                solution = x * y
            elif order[0] == "divide":
                solution = x / y
            order.pop(0)
            order.pop(0)
            order.pop(0)
        if order[0] == "addvar'" or order[0] == "subtractvar'" or order[0] == "multiplyar'" or order[0] == "dividevar'":
            if order[0] == "addvar'":
                solution = int(order[2]) + int(order[3])
            elif order[0] == "subtractvar'":
                solution = int(order[2]) - int(order[3])
            elif order[0] == "multiplyvar'":
                solution = int(order[2]) * int(order[3])
            elif order[0] == "dividevar'":
                solution = int(order[2]) / int(order[3])
            if order[1] == "1":
                var1 = solution
            elif order[1] == "2":
                var2 = solution
            elif order[1] == "3":
                var3 = solution
            order.pop(0)
            order.pop(0)
            order.pop(0)
            order.pop(0)

        # if
        if order[0] == "if":
            if order[1] == "='":
                if not int(order[2]) == int(order[3]):
                    while not order[0] == "close":
                        order.pop(0)
            if order[1] == ">'":
                if not int(order[2]) > int(order[3]):
                    while not order[0] == "close":
                        order.pop(0)
            if order[1] == "<'":
                if not int(order[2]) < int(order[3]):
                    while not order[0] == "close":
                        order.pop(0)
            if order[1] == "=":
                if order[2] == "1":
                    x = int(var1)
                elif order[2] == "2":
                    x = int(var2)
                elif order[2] == "3":
                    x = int(var3)
                if order[3] == "1":
                    y = int(var1)
                elif order[3] == "2":
                    y = int(var2)
                elif order[3] == "3":
                    y = int(var3)
                if not x == y:
                    while not order[0] == "close":
                        order.pop(0)
            if order[1] == ">":
                if order[2] == "1":
                    x = int(var1)
                elif order[2] == "2":
                    x = int(var2)
                elif order[2] == "3":
                    x = int(var3)
                if order[3] == "1":
                    y = int(var1)
                elif order[3] == "2":
                    y = int(var2)
                elif order[3] == "3":
                    y = int(var3)
                if not x > y:
                    while not order[0] == "close":
                        order.pop(0)
            if order[1] == "<":
                if order[2] == "1":
                    x = int(var1)
                elif order[2] == "2":
                    x = int(var2)
                elif order[2] == "3":
                    x = int(var3)
                if order[3] == "1":
                    y = int(var1)
                elif order[3] == "2":
                    y = int(var2)
                elif order[3] == "3":
                    y = int(var3)
                if not x < y:
                    while not order[0] == "close":
                        order.pop(0)
            for i in range(4):
                order.pop(0)
        if len(order) < 1:
            run = 0

2 Answers

0 votes
by
Im just assuming you're asking why the first while loop isn't repeating. It may be just python being python which is definitely an unsatisfactory answer but it may just be what's happening. It could also be a sort of command overflow where you type multiple commands at once (as in, you type run() multiple times) it could be indentation, it could also be a silent error just breaking the program.

Idrk what you are trying to do as this code is very confusing. I also have no idea what your question is so I'm just assuming.

Honestly, I would just ask AI because it'll probably know what you are trying to do
1 vote
by

Not to be rude, but that code is pretty poorly written. I tried dissecting it to figure out what the heck was going on and had absolutely no luck. Consider eliminating the parts that aren't necessary to your question. If required, write a new script, illustrating your goal and what went wrong.

Just some general advice for any issues you encounter:

    -Add plenty of 'debug' lines (that is, print statements that log where you are at in the code) around the problematic code to pinpoint the direct issue you are having.

    -If you are planning on getting serious about programming, join a site like Stack Overflow (you can get more precise and accurate answers there) and learn how to ask good questions.

   -Lastly, use consistent naming conventions. Variable names like imput is pretty confusing and makes understanding your code really hard. 

Good luck with your programming! Once you fix your question or post on Stack Overflow reply to this answer and I'll get back with you.

by 🌌 Galactic Overlord (2.65m points) [prez/mod]

skull.

by
Who are you, sir?
by 🪐 Master (1.62m points)
That’s a guy you do NOT want to mess with. He’s a mod and also everyone on KT defends him to death. Also he has the most points.
by 👑 Grand Master (2.43m points)
I'm assuming Pumpkin is saying the skull emoji because you are not entirely correct, Undefined. But I wouldn't know for sure, as I am not a coder.
by
Got it.
by 🪄 Spell Caster (4.0k points)
Tell me whats wrong: ❌

Insult my programming: ✅
by
@Carmel

     Don't get me wrong, I admire your programming skills and ambition at such a young age and it makes me smile that there are other young programmers out there. I just want to give you some advice and make sure you learn programming the best way. It's perfectly fine if your code is as sloppy as a sloppy joe (dumb joke, sorry), I just want to make sure you learn some good practices early on so you don't end up stuck with some terrible programming habits.

@NobodyImportant

     I think he was just caught off guard at my harsh criticism of their code.

Related questions

7 votes
3 answers 624 views
5 votes
4 answers 752 views
8 votes
3 answers 398 views
asked Apr 28, 2025 in Technology by A fungi 🃏 Illusionist (12.3k points)
11 votes
2 answers 557 views
asked Oct 10, 2016 in Technology by William
40 votes
20 answers 21.6k views
4 votes
4 answers 400 views
7 votes
1 answer 339 views
11 votes
3 answers 292 views
13 votes
3 answers 514 views
asked Aug 17, 2016 in Other by anonymous
2 votes
1 answer 66 views
3 votes
1 answer 136 views
3 votes
1 answer 131 views
9 votes
1 answer 243 views
asked Jan 21, 2025 in Technology by Lost monstercharz 🧝 Drifter (410 points)
8 votes
5 answers 313 views
10 votes
3 answers 366 views
12 votes
3 answers 604 views
...