<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<tt>On 2012/04/12 06:42 AM, john moore wrote:</tt>
<blockquote
cite="mid:1334205766.87330.YahooMailClassic@web160503.mail.bf1.yahoo.com"
type="cite">
<pre wrap=""><tt>Hello Pyhton World,
I'm new at this and was wondering how I create a number of user specified lists?
Example:
"How many list would you like to create?"
User inputs 5
creates five lists,
list1 []
list2 []
list3 []
list4 []
list5 []
I can create one with append, but I don't know how to loop it to create five different named list..
_______________________________________________
Tutor maillist - <a class="moz-txt-link-abbreviated" href="mailto:Tutor@python.org">Tutor@python.org</a>
To unsubscribe or change subscription options:
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a>
</tt></pre>
</blockquote>
<tt>You can use vars() to create the variables on the fly. vars() is
just a dictionary containing the variable name as the key, and the
data as the value so you can do `vars()['list1'] = []` and it's
easy enough to create them en masse<br>
<br>
# Set the start to 1, and add 1 to what the user inputted<br>
# as range/xrange doesn't include the top number<br>
for i in xrange(1, user_input + 1):<br>
vars()['list%s' % i] = []<br>
<br>
Hope that helps.<br>
</tt>
<div class="moz-signature"><tt>-- <br>
</tt>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Email Signature</title>
<style type="text/css">
p { font-size:8.5pt; font-family: Arial, Helvetica, sans-serif; color: #000;}
.subscribe {font-weight:bold; font-style:italic;}
.compuscan {color: #c60c30; letter-spacing:2px; text-transform:uppercase; font-weight:bold}
.green {color:#093;}
</style>
<p><tt>Christian Witts<br>
Python Developer<br>
<em class="green"></em></tt></p>
</div>
</body>
</html>