468,287 Members | 2,018 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,287 developers. It's quick & easy.

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

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
1 1149

"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.

Similar topics

23 posts views Thread by Fuzzyman | last post: by
9 posts views Thread by Yomanium Yoth Taripoät II | last post: by
2 posts views Thread by Greg Lindstrom | last post: by
2 posts views Thread by Ishwar Rattan | last post: by
37 posts views Thread by Gregor Horvath | last post: by
8 posts views Thread by localpricemaps | last post: by
77 posts views Thread by Nick Maclaren | last post: by
1 post views Thread by mmm | last post: by
reply views Thread by Hatem Nassrat | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.