#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0

    i expected "," or "]" error


    I am learning some basic python, and while working on a programm I encountered an error, and I can't wrap my head around why this is wrong. It says that i expected "," or "]", why does it say that and how could I resolve it?

    Code:
    def figure_2():
        can.delete(ALL)
        cc = [[100, 100, 80, "red"],
              [70, 70, 15, "blue"],
              [130, 70, 15, "blue"],
              [70, 70, 5, "black"],
              [130, 70, 5, "black"],
              [44, 115, 20, "red"],
              [156, 115, 20, "red"],
              [100, 95, 15, "purple"],
              [100, 145, 30, "purple"],
        i = 0
        while i < len(cc):
            el = cc[i]
            cercle(el[0], el[1], el[2], el[3])
            i += 1
    
    fen = Tk()
    can = Canvas(fen, width =200, height =200, bg="ivory")
    can.pack(side =TOP, padx= 5, pady= 5)
    b1 = Button(fen, text="dessin 1", command =figure_1)
    b1.pack(side =LEFT, padx =3, pady =3)
    b2 = Button(fen, text="dessin 2", command = figure_2)
    b2.pack(side =RIGHT, padx =3, pady =3)
    fen.mainloop()
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Joensuu, Finland
    Posts
    438
    Rep Power
    67
    Code:
        cc = [[100, 100, 80, "red"],
              [70, 70, 15, "blue"],
              [130, 70, 15, "blue"],
              [70, 70, 5, "black"],
              [130, 70, 5, "black"],
              [44, 115, 20, "red"],
              [156, 115, 20, "red"],
              [100, 95, 15, "purple"],
              [100, 145, 30, "purple"],
    You have a missing ] on the last line.
    My armada: openSUSE 13.1 (home desktop, home laptop), Crunchbang Linux 11 (work laptop), Trisquel GNU/Linux 6.0.1 (mini laptop), Ubuntu 14.04 LTS (server), Android 4.2.1 (tablet), Windows 7 Ultimate (testbed)
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0
    Originally Posted by SuperOscar
    Code:
        cc = [[100, 100, 80, "red"],
              [70, 70, 15, "blue"],
              [130, 70, 15, "blue"],
              [70, 70, 5, "black"],
              [130, 70, 5, "black"],
              [44, 115, 20, "red"],
              [156, 115, 20, "red"],
              [100, 95, 15, "purple"],
              [100, 145, 30, "purple"],
    You have a missing ] on the last line.
    Stupid of me, Thanks
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,955
    Rep Power
    481
    Use a code editor that checks these problems!
    I recommend emacs.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo