Solved

Arranging data in a list

Posted on 2006-07-05
2
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Plenty of writing has gone on the web trying to compare Python with other competitive programming languages and vice versa. However, not much has been put into a wholistic perspective. This article should help you decide whether to adopt Python as a…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

734 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