Making a loop with lists
<p>I am new to Python and would like to create a print function that repeats itself for each item in a list (this is only an example my actual code will be for something else)</p>

<pre><code>cars.list = [Honda, Chevrolet, Suzuki, Ford]

price.list = [5600, 11500, 6600, 1020]
</code></pre>

<p>The prices and car lists are in the same order so Honda is $5600, Chevrolet is 11500 ect. I'd like it to run a loop for each of the cars that prints this:</p>

<pre><code>while count in cars.list:
       print("The car type is" Honda/Chev ect. "The price is" 5600, 11500 ect"
</code></pre>

<p>I want it to repeat the loop for as many cars are in the <code>cars.list</code>, as I will add an option for the user to add more cars so the program cannot rely on knowing the specific cars in a list and copying the print statement for each one. It needs to repeat the print statement for every car, replacing the price and car type each time with the next one in the list.</p>

<p>You can use <a href="https://docs.python.org/3/library/functions.html#zip" rel="nofollow"><code>zip</code></a> to associate the cars and prices together in an iterator of tuples, then iterate over those tuples while printing what you want.</p>

<pre><code>cars = ['Honda', 'Chevrolet', 'Suzuki', 'Ford']
prices = [5600, 11500, 6600, 1020]

for car, price in zip(cars, prices):
    print('The car type is {} and the price is {}.'.format(car, price))
</code></pre>

<p><strong>Output:</strong></p>

<pre><code>The car type is Honda and the price is 5600.
The car type is Chevrolet and the price is 11500.
The car type is Suzuki and the price is 6600.
The car type is Ford and the price is 1020.
</code></pre>

python list python-3.x printing count