(Nov-19-2019, 03:01 AM)Mike2607 Wrote: if I wanted to do this with out adding commas or removing the spaces is this possible?
I think that this assignment more about cleaning string than printing table. As there are strings which don't have spaces between state abbreviation and zip-code one should normalise them (split to chars and construct new string without spaces) and use index (all states have two-letter abbreviation):
for row in mycities: city, state_and_zip = row.split(',') location = ''.join(char for char in state_and_zip.split()) print(f'{city:20}{location[:2]:3}{location[2:]:10}')
Output:Cape Girardeau MO 63780
Columbia MO 65201
Kansas City MO 64108
Rolla MO 65402
Springfield MO 65897
St Joseph MO 64504
St Louis MO 63111
Ames IA 50010
Enid OK 73773
West Palm Beach FL 33412
International Falls MN 56649
Frostbite Falls MN 56650
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.