Splitting list items and adding value to them in python
<p>I want to split list items then add values to them. To do this I am required to take the first sentence; split it into a list; use the <code>isdigit()</code> to determine if the list element is a digit then add 1 to the element; join the new list elements together using <code>join()</code>. It needs to be done using the for loop with enumerate. </p>

<p>This is my code :</p>

<pre><code>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
printer = a.split(" ")
print printer
if printer.isdigit():
</code></pre>

<p>Looks like you want something like this<br>
I have replaced <code>li[0]</code> and other variables with a string "Some_Value" because I did not knew the value of those variables</p>

<pre><code>a="You would like to visit " + "Some_Value" +" as city 1 and " + "Some_Value" + " as city 2 and "+ "Some_Value" + " as city 3 on your trip"
a = a.split(" ")
index = 0

for word in a:
    if word.isdigit():
        a[index] = str(int(word) + 1)
    index += 1
print " ".join(a)
</code></pre>

<p><strong>OP</strong><br>
<code>You would like to visit Some_Value as city 2 and Some_Value as city 3 and Some_Value as city 4 on your trip</code></p>

python