I'm taking the input for a name in Tkinter, but it's giving an error when I want to check if only alphabets are entered:
t1=Label(text="Name:")
t1.place(x=40,y=100)
name=Entry(t)
if name.isalpha():
print("Valid")
else:
print("Invalid")
How do I check the validity of the input?
You want to check the value of your input field. Use name.get().isalpha()
.
name
is just a instance of Entry. You want the value of this entry field. You can get this by calling get()
on the Entry instance.
isalpha()
is defined on str
ings only.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.