I am trying to run the following code:
from tkinter import *
import random
root=TK()
root.title("Password Generator")
root.geometry("640x480")
label=Label(root)
array_3D=[[['1','2','3','4','5','6'],["Head","Tail"],["A","B","C","D","E","F","G","H"]]
def new_password():
random_no_1=random.randint(0,5)
random_no_2=random.randint(0,1)
random_no_3=random.randint(0,7)
letter_1=str(array_3D[0][0][random_no_1])
letter_2=str(array_3D[0][1][random_no_2])
letter_3=str(array_3D[0][2][random_no_3])
label["text"]=letter_1 letter_2 letter_3
btn=Button(root,text="Generate 'Weak' Password",command=new_password)
btn.place(relx=0.5,rely=0.5,anchor=CENTER)
label.place(relx=0.5,rely=0.6,anchor=CENTER)
root.mainloop()
It gives me the following error: File "main.py", line 9 def new_password(): ^ SyntaxError: invalid syntax
What is the problem?
Tried changing Indentation, but Nothing Happened
CodePudding user response:
You missed a closing bracket for array_3D
Try
array_3D=[[['1','2','3','4','5','6'],["Head","Tail"],["A","B","C","D","E","F","G","H"]]]
CodePudding user response:
Seems like you forgot a closing ] bracket from the list of list of lists before.
array_3D=[[['1','2','3','4','5','6'],["Head","Tail"],["A","B","C","D","E","F","G","H"]]
3 open only 2 close at the end.