0

When iIrun this program there is a syntax error and the 'def überprüfen()' is marked red. What is wrong?

from tkinter import *
password = str(eval(entry.get())

In this part is the syntax error:

 def überprüfen(event):
     if password:
                if len(password) > 8:
                        res.configure(text = "Ihr Passwort ist zu kurz")
                else:
                        res.configure(text = "Ihr Passwort ist gut")
     else:
                res.configure(text = "Bitte geben sie ihr Passwort ein")


w = Tk()
Label(w, text="Ihr Passwort: ").pack()
entry = Entry(w)
entry.bind("<Return>", überprüfen())
entry.pack()
res = Label(w)
res.pack()
w.mainloop()

The program should test a password if it is good. Thanks for helping :D

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
Noah
  • 1
  • 1
  • 1
  • 1
    Add `# -*- coding: utf-8 -*-` at first line of your source file. Or use the ascii characters to define identifiers. – stamaimer Aug 07 '17 at 05:16
  • 1
    The `from ... import` line shouldn't be indented, and neither should the `def` line. Also, the `password =` line is missing the third `)`. – Kevin J. Chase Aug 07 '17 at 06:02
  • If you are really using Python 3, make sure that the file is saved as UTF-8. Nothing else needs to be done to allow unicode identifiers. – poke Aug 07 '17 at 06:45
  • You say the `def` line *“is marked red”* – Where exactly are you looking at this? Are you using an IDE? – poke Aug 07 '17 at 06:47

1 Answers1

0

Add this line at the first line of your code.

# -*- coding: utf-8 -*-

  • Since OP is using Python 3, specifying the encoding explicitly like that [is not necessary](https://stackoverflow.com/q/14083111/216074) and should probably even be avoided. – poke Aug 07 '17 at 06:47