Re: What's wrong with this code?

Discussion in 'Python' started by Emile van Sebille, Jul 23, 2012.

  1. On 7/23/2012 7:50 AM Stone Li said...
    > I'm totally confused by this code:
    >
    > Code:
    >
    > a = None
    > b = None
    > c = None
    > d = None
    > x = [[a,b],
    > [c,d]]
    > e,f = x[1]
    > print e,f


    This prints the first None,None

    > c = 1
    > d = 2
    > print e,f


    And nothing has happened to e or f, so this is the second None,None

    Why do you expect 1,2?

    Emile



    > e = 1
    > f = 2
    > print c,d
    >
    > Output:
    >
    > None None
    > None None
    > 1 2
    >
    >
    > I'm expecting the code as:
    >
    > None None
    > 1 2
    > 1 2
    >
    >
    > What's wrong?
    > And this question made my GUI program totally out of control.
    > Thanks
    >
    >
     
    Emile van Sebille, Jul 23, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    3
    Views:
    2,223
    Ralf Hildebrandt
    Sep 10, 2003
  2. willem oosthuizen

    What is wrong with the following code?

    willem oosthuizen, Oct 10, 2003, in forum: VHDL
    Replies:
    9
    Views:
    1,312
  3. Matthew
    Replies:
    7
    Views:
    746
    Priscilla Walmsley
    Jan 7, 2005
  4. David. E. Goble
    Replies:
    9
    Views:
    494
    David. E. Goble
    Feb 2, 2005
  5. kiran
    Replies:
    12
    Views:
    1,162
    Scott Sauyet
    Dec 7, 2011
Loading...

Share This Page