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>You can build the string with a combination of <a href="https://docs.python.org/2/library/stdtypes.html#str.format" rel="nofollow">string formatting</a>, <a href="https://docs.python.org/2/library/stdtypes.html#str.join" rel="nofollow"><code>str.join</code></a> and <a href="https://docs.python.org/2/library/functions.html#enumerate" rel="nofollow"><code>enumerate</code></a>:</p>

<pre><code>a = "You would like to visit {} on your trip".format(
    " and ".join("{} as city {}".format(city, i)
                 for i, city in enumerate(li, 1)))
</code></pre>

<p><code>str.join()</code> is given a <a href="https://docs.python.org/2/reference/expressions.html#generator-expressions" rel="nofollow">generator expression</a> as the iterable argument. The curly braces (<code>{}</code>) in the strings are <a href="https://docs.python.org/2/library/string.html#formatstrings" rel="nofollow">replacement fields</a> (placeholders), which will be replaced by positional arguments when formatting. For example</p>

<pre><code>'{} {}'.format('a', 'b')
</code></pre>

<p>will produce the string <code>"a b"</code>, as will</p>

<pre><code># explicit positional argument specifiers
'{0} {1}'.format('a', 'b')
</code></pre>

python