I am trying to read  in a string from the user input and if the string is a 
number then I would print out the numbers + 1.  For example if the user enters:
I have 320 dollars to buy grocery.  My program would print out: I have 321 to 
buy grocery.  However, the code that I have listed below would print out: I 
have 431 dollars to buy grocery.  How do I fix this program so that it print 
out 321 vs. 431?

=====================================================

#!/usr/bin/python3



def WhereAreNumbers(a_list):

    for index, element in enumerate(a_list):

        if element.isdigit():

            new_number = int(element)

            print (new_number + 1, end="")

        else:

            print(element,end="")



def Test():

    answer = input("Please enter your strings:")

    if answer:

        WhereAreNumbers(answer)

Test()

==========================================

Please enter your strings:I have 320 dollars to buy grocery

I have 431 dollars to buy grocery


Thanks;


Lily
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to