How to dynamically print list values?
<p>This Code Works Fine.....But it's like static.
I don't know what to do to make it work in dynamic way?
I want:-
When user inputs 3 number of cities it should give</p>

<blockquote>
  <p>a="You would like to visit "+li[0]+" as city 1 and " +li[1]+ " as city
  2 and "+li[2]+" as city 3 on your trip"</p>
</blockquote>

<p>Similaraly when input is 5 cities it should go to 5 times</p>

<pre><code>li = []
global a

number_of_cities = int(raw_input("Enter Number of Cities --&gt;"))
for city in range(number_of_cities):
   li.append(raw_input("Enter City Name --&gt;"))
print li
a="You would like to visit "+li[0]+" as city 1 and " +li[1]+ " as city 2 and "+li[2]+" as city 3 on your trip"      
print a
a = a.split(" ")
print "\nSplitted First Sentence looks like"
print a
print "\nJoined First Sentence and added 1"
index = 0
for word in a:
   if word.isdigit():
      a[index] = str(int(word)+1)
   index += 1
print " ".join(a)
</code></pre>

<p>create another for loop and save your cities to an array. afterwords, concat the array using "join" and put put everything inside the string:</p>

<pre><code>cities = []
for i in range(0,len(li), 1):
    cities.append("%s as city %i" % (li[i], i))

cities_str = " and ".join(cities)
a = "You would like to visit %s on your trip" % (cities_str) # edited out the + sign
</code></pre>

python