Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > Python

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-18-2010, 08:12 PM   PM User | #1
whatg
New Coder

 
Join Date: Jan 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
whatg is an unknown quantity at this point
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..
whatg is offline   Reply With Quote
Old 08-18-2010, 08:18 PM   PM User | #2
whatg
New Coder

 
Join Date: Jan 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
whatg is an unknown quantity at this point
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!
whatg is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:02 PM.


Advertisement
Log in to turn off these ads.