Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: appending list

  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    45
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question appending list

    *And here I had though I'd grabbed the basic concepts*I know this might seem simple but don't know whats going on. Trying to make a while loop which adds to a list each time it goes round.


    def squares():
    y = 0
    l = []
    while y <= 4:
    y = y + 2
    d = l.append(y)
    print(d)



    So I would expect l = [2] the first time it entered the loop and then l = [2,4], which it seems to be doing in debugger but when it comes to printing the value it simply prints 'none'. Any ideas? Thanks
    Last edited by whatg; 08-18-2010 at 08:19 PM.

  • #2
    New Coder
    Join Date
    Jan 2010
    Posts
    45
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Yay!

    I know what I did! I was appending to the list with the variable name 'l' and tried to print the variable 'other letter' so of course it wasn't printing anything!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •