954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Don't know why an empty list is printed

I can't work out why when i try to print the list(listProb....s) it prints the empty list, i'm not setting them to the empty list after this code or anything, and when i print the normDistProb's on their own it prints fine):

for i in range(0,12):
listProbFog.append(normDistProb(dayValues[i], fogAve[i], fogVar[i]))
listProbSnow.append(normDistPr...ob(dayValues[i], snowAve[i], snowVar[i]))
listProbRain.append(normDistProb(dayValues[i], rainAve[i], rainVar[i]))
listProbNone.append(normDistProb(dayValues[i], noneAve[i], noneVar[i]))


Thanks

p.s. listProb's are indented

spe_eddy
Newbie Poster
13 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

What does the function normDistProb return? The first attempt to debug this should be to print it

for i in range(0,12):
    listProbFog.append(normDistProb(dayValues[i], fogAve[i], fogVar[i]))
    print normDistProb(dayValues[i], fogAve[i], fogVar[i])
    print listProbFog
    # the other lists are just extra cruft until you get this problem solved
woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
 

Maybe the listProb lists have already an empty list inside after entering the loop. You can print their content before entering the loop.

I guess that normDistProb returns an empty list somehow.

GDICommander
Posting Whiz in Training
211 posts since Jun 2008
Reputation Points: 72
Solved Threads: 26
 

i got it - my normDistProb functioned looped popping elements from the list so it worked whilst inside the loop and the desired results were obtained, so basically there was no way anyone could answer this question with the information i provided, sorry!

spe_eddy
Newbie Poster
13 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

You should mark this thread solved, even you solved it yourself.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: