Assistance with code error

Can anyone advise me on the following:

import tkinter as tk

from tkinter import simpledialog

from tkinter import messagebox

root = tk.Tk()

root.withdraw()

user_input = simpledialog.askstring(title = “Ticket Calculator”, prompt = "Enter ticket number: ")

tk.messagebox.showinfo(“Dropped number”, user_input[:5])

tk.messagebox.showinfo(“Remainder”, int(user_input[:5]) % 7)

user_input = int(user_input[:5] % 7)

remainder = int(user_input[:5] % 7)

if user_input == remainder:

True

else:

False

I need to get a True or False statement in the message box if the remainder is equal to the same number that has been spliced from the ticket number.

e.g.

123454
Spliced number will be 4
Working out the remainder it will also be 4
Thus my statement is True.

But I am struggling to get the True and False statments in the message box as well as an error with my IF statment:

user_input = int(user_input[:5] % 7)
~~~~~~~~~~~~~^
TypeError: not all arguments converted during string formatting

Is this an exam question? If so, we cannot help.

If that is not the case, then please format your code.

This guide might help when posting questions:

Not sure that Python’s GUI is even taught on CC, but then a lot has been added to the curriculum in the past couple of years, so I could well be wrong. Does Flask use the native GUI?

At any length I don’t recognize that project and can only assume it is an outside project, maybe a class assignment. Can’t see it being a test question. Still, there is no way to help the user without running the code locally which I have no motivation to do. Maybe some other expertise with the Python GUI will come along. Won’t hold my breath.

1 Like

You’re right; it’s not taught on CC as far as I can tell.
I said “exam,” but I meant class assignment. :woman_facepalming:

1 Like