Well, I am assuming that by this you mean converting user input into a string, and then extracting the numerals (0-9) from it. Next time, please tell us your version of Python. I'll do my best to help with this. You might try the following:
the_input = input("Insert string here: ") # change to raw_input in python 2 after = "" for char in the_input: try: char = int(char) except: after += char If other symbols might be in the string ($, @, etc.), then you might use the_input = input('Insert string here: ') # change to raw_input in python 2 after = '' not_allowed = '1234567890-=!@#$%^&**()_+,./<>?`~[]{}\\|' for char in the_input: if char in not_allowed: pass else: after += char This method requires more typing, but it works with a wider variety of characters. Hopefully this helped. On Thu, Nov 17, 2011 at 8:45 PM, Nidian Job-Smith <nidia...@hotmail.com>wrote: > > Hi all, > > In my programme I am encoding what the user has in-putted. > > What the user inputs will in a string, which might a mixture of letters > and numbers. > > However I only want the letters to be encoded. > > > Does any-one how I can only allow the characters to be encoded ?? > > Big thanks, > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor