I'm just starting programming. I'm want to do a simple Ohm's law calculator. I'm struggling to check if the entry is empty or if it has one or more zeros in it. How can I check if it has one or more zeros in it?
from tkinter import *
import math as m
def doMath():
U = entryU.get()
I = entryA.get()
if I == "0" or \
I == "" or \
U == "":
labelR.config(text="Error", bg= "red")
else:
R = float(U)/float(I)
labelR.config(text="Resistance: {:.2f}\u03A9".format(R), bg="white")
frame = Tk()
entryU = Entry(frame)
entryU.place (x=95, y= 60, width= 250, height =30)
entryA= Entry(frame)
entryA.place(x=95, y=100, width= 250, height=30)
buttonMath = Button(frame, text="R",command = doMath)
buttonMath.place(x=360, y=70, width=120, height=50)
labelR = Label (frame, text="Resistance: ")
labelR.place(x=10, y= 145)
frame.mainloop()
That's what I have but as soon as I have "00" in my string this won't work obviously and if I try to just check if I==0 it won't work because I can't compare string with a int (I suppose). I also want to be able to calculate with decimal numbers. Thanks for any help!