Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I've a program which gives output as different lists for different values of n in for loop. I've to display these lists all together as final output of the program.
Suppose:
#####
for n in range(0,2):
when n=0 result is LIST1
when n=1 result is LIST2
when n=2 result is LIST3

as for the final output of the program I need to display:

LIST1
LIST2
LIST3
#####

How to do this? I think I've to create new list to store the different values of n, but how can I do it?
Posted

1 solution

This won't even compile, but maybe you just need to format the text of your question. Please use "Improve question" and <pre> tags for source code.

Why helping with the code when the original idea is wrong? All those repeated conditional statements are evil. (You probably meant "if", not when".) Where did you get those LIST1, LIST2..? You should not have these variables at all. They should be list[0], list[1]… in first place. What do you think arrays are for. In this case, no ifs no buts, just one loop.

It makes no sense to ask about very basic syntax before you read the documentation http://www.python.org/doc/[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900