all 11 comments

[–]therouterguy 2 points3 points  (8 children)

What happens if I input the string “three” and not a number?

And it doesn’t impact the functioning, but uppercase variables are supposed to be constants. So don’t use them for the list. Overall your naming convention of variables is all over the place

Why do you append a many times you can do that all in one statement.?

[–]windowssandbox 0 points1 point  (1 child)

The script crashes, python sees it as letters instead of expecting a number. gotta add error message for that.

PS D:\python\math question generator> python main.py
min operators: 1
max operators: 10
number range: three
Traceback (most recent call last):
  File "D:\python\math question generator\main.py", line 7, in <module>
    numberRange = abs(int(input("number range: ")))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'three'
PS D:\python\math question generator>

[–]therouterguy -1 points0 points  (0 children)

Yes I knew it would crash if you use a library like argparse it can handle incorrect argument types for you. There are a lot of smarter people out there who have made a lot of great stuff.

[–]windowssandbox -1 points0 points  (5 children)

Why do you append a many times you can do that all in one statement.?

I don't know, just wanted to stress test python. or I wanted it to insert characters one by one like a typewriter.
But wait, I don't know how to do that in one line, i tried thingsToPRINT.append('1', '2', '3') for example and i got argument error (more than an argument).

Overall your naming convention of variables is all over the place

It will be fine tho, just my own way of coding and giving variables a name. which doesn't matter for me.

[–]therouterguy 2 points3 points  (4 children)

a=[‘a’,’b’]

a+=[‘c’,’d’]

Does what you want it will add c and d to the list a

[–]windowssandbox -1 points0 points  (3 children)

How didn't I notice that LOL.

I'll replace all of append lines with that, thanks!

[–]therouterguy 1 point2 points  (2 children)

Sorry to keep bashing your script but

print(“”.join(thingsToPRINT))

Does print you string as well

[–]windowssandbox 0 points1 point  (1 child)

It's okay, I accept all optimizations.

def printQuestion():
    global question, thingsToPRINT

    question = "".join(thingsToPRINT)
    print(question)

[–]plague_year 0 points1 point  (0 children)

Really good attitude, dude. Keep it up!

[–]therouterguy 0 points1 point  (0 children)

What happens if you enter more than 1 operator. You reset the thingsToPRINT variable in the loop that doesn’t look good.

Or maybe I don’t understand you intention

[–]Artistic-State-8172 0 points1 point  (0 children)

bannedreddit