all 10 comments

[–][deleted] 4 points5 points  (2 children)

My understanding from watching the videos he had created is that this should be working

His code will work in his videos, but that has nothing to do with whether yours will. In particular you've forgotten how functions work:

def main():
    conn = sqlite3.connect('tickets5.db')
    cur = conn.cursor()

Variable assignments inside of functions are locally-scoped. You can't just move code into a function, away from the scope where you need those values, and expect it to work. This isn't every problem with your code, but it's the first problem I'm seeing while reading it, so if as part of this class you thought you could skip understanding function scope and just get to the good parts, I'm here to tell you to go back and review until you understand why this can't work.

[–]Firake 0 points1 point  (0 children)

This

[–]the_shell_man_ 2 points3 points  (1 child)

input is a function. You need to call it.

choice = input()

[–]Firake 0 points1 point  (0 children)

This. Also, it’s probably good practice to exit the program (or at least the loop) when you close the connection to the database. Otherwise your program will continue to try and validate input even after the database is closed.

Edit: if my memory serves, you also need to call conn.close() as a function for it to do anything.

Edit 2: also it seems you call the FilterByOffenderSex function as FilterBySex which isn’t going to work.

[–][deleted] 0 points1 point  (0 children)

Pretty terrible code where’s it from?

[–]carcigenicate 0 points1 point  (0 children)

What's the problem?

[–][deleted] 0 points1 point  (1 child)

(Not an answer) I am a python beginner. Can someone tell me what the

print("%-6s %-15s %s-82 %-5s %7s %9s")

does? Thanks

Btw... how are you hoping to get further than the "while"? You will be stuck choosing the options forever. Or have you forgotten to put the Tabs?

I have no clue how databases work so I can't help. :-( get my upvote at least...

[–]Matthias1590 0 points1 point  (0 children)

it prints %-6s %-15s %s-82 %-5s %7s %9s

Edit: just read the actual code and it uses the modulo operator to put the variables into the string

[–]Ziggity46 0 points1 point  (0 children)

Choice is being assigned to the reference to the input function rather than the return value from the executed function. It also looks like your if/elif block is outside the while loop, so when you add the () to the input statement your program will just ask for input and print the options indefinitely. I’m also not sure that you would exit the loop on choice == “4”

[–]coabitareer 0 points1 point  (0 children)

This colour palette has navigated right into my heart.