Solved

Arranging data in a list

Posted on 2006-07-05
2
240 Views
Last Modified: 2010-04-16
Hi,

This question is related to a previous question that was excellently answered:

http://www.experts-exchange.com/Programming/Programming_Languages/Python/Q_21905315.html



What I now would like to do is to create a list of the following structure:
[GarageName*Make-Model , GarageName*Make-Model , GarageName*Make-Model ...... ]

I have no problem making a list of the following structure:
[[GarageName, Make, Model] , [GarageName, Make, Model] , [GarageName, Make, Model] .....]


, but I need the cars to be in the first list format, as this is the format that they appear in another inventory.

So I need to use some kind of string function that will convert the object values to a string??


Hope you can help,
John
0
Comment
Question by:JohnAutoSales
2 Comments
 
LVL 14

Accepted Solution

by:
RichieHindle earned 500 total points
ID: 17045826
How about this:

LIST = [["wood road", "toyota", "yaris"], ["john street", "ford", "mondeo"]]
result = ["%s*%s-%s" % (garage, make, model) for garage, make, model in LIST]
print result
0
 

Author Comment

by:JohnAutoSales
ID: 17046519
Perfect!!

Thank you.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Python tuple index error 4 87
Python 2.7 - French characters 6 104
Edit linux file using python 4 58
troubleshoot a python script 8 21
The really strange introduction Once upon a time there were individuals who intentionally put the grass seeds to the soil with anticipation of solving their nutrition problems. Or they maybe only played with seeds and noticed what happened... Som…
Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question