DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   List Index Question (http://www.daniweb.com/forums/thread156302.html)

SoulMazer Nov 10th, 2008 12:14 am
List Index Question
 
First off, I know that to set an indexed variable, say, mylist[3] = "Hello". I also know that you wouldn't be able to set mylist[3] if you didn't first state:

[code = python]mylist = ["Whatever", "Whatever", "Whatever", "Whatever"][/code]

But, if you had a variable with an extremely large index, it would be a pain in the rear to type " "Whatever", " that many times.

So, my question is, is there a not-tedious way to do this? Like Ruby's mylist = "Whatever" * 100?

Thanks in advance.

Gribouillis Nov 10th, 2008 1:20 am
Re: List Index Question
 
this way
mylist = ["whatever"] * 100

SoulMazer Nov 10th, 2008 1:57 am
Re: List Index Question
 
Problem solved. Thanks a lot.


All times are GMT -4. The time now is 11:12 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC