print() a list
DarkBlue
pict100 at gmail.com
Sat Sep 5 01:53:57 EDT 2009
I am trying to get used to the new print() syntax prior to installing
python 3.1:
test=[["VG", "Virgin Islands, British"],["VI", "Virgin Islands, U.S."],
["WF", "Wallis and Futuna"],["EH", "Western Sahara"],["YE", "Yemen"],
["ZM", "Zambia"],["ZW", "Zimbabwe"],]
#old print
for z in test:
if z[0].startswith('W'):
print z[0] , z[1]
print
# new print()
# now a list would have to be printed like this to be equal to old
print ?
for z in test:
if z[0].startswith('W'):
print('%s %s') % (z[0] , z[1])
print
# this output prints the brackets etc. too, not what we want
for z in test:
if z[0].startswith('W'):
print(z[0] , z[1])
print
on python 2.6 I get following output:
WF Wallis and Futuna
WF Wallis and Futuna
('WF', 'Wallis and Futuna')
Before actually installing python 3.1 my question is if the py2to3
converter also considers this situation ?
Thanks
Db
More information about the Python-list
mailing list