By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,096 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,096 IT Pros & Developers. It's quick & easy.

Re: Creating A Tuple From A List, Adding To Tuple As You Do

P: n/a
Hi Jeff,

Jeff Nyman <je*******@gmail.comwrites:
I did try this:

for count in range(0, len(DC_List)):
DC_List.insert(count, '')
On additional note: You can be quite sure you'll never have to iterate
over the length of a list (or tuple) in python. Just iterate over the
list itself:

for DC in DC_List:
# do something with DC.

Yours
Karsten
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Karsten Heymann" <ka*************@blue-cable.netwrote in message
news:87************@ara.blue-cable.net...
| Hi Jeff,
|
| Jeff Nyman <je*******@gmail.comwrites:
| I did try this:
| >
| for count in range(0, len(DC_List)):
| DC_List.insert(count, '')
|
| On additional note: You can be quite sure you'll never have to iterate
| over the length of a list (or tuple) in python. Just iterate over the
| list itself:
|
| for DC in DC_List:
| # do something with DC.

Unless you want to modify the list in place.

for i in range(len(cities)):
cities[i] = (cities[i], '')

#or perhaps better

for i,city in enumerate(cities):
cities[i] = (city,'')

tjr

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.