En Thu, 05 Feb 2009 04:48:13 -0200, Spacebar265 <spacebar...@gmail.com> escribió:
Hi. Does anyone know how to scan a file character by character and have each character so I can put it into a variable. I am attempting to make a chatbot and need this to read the saved input to look for spelling mistakes and further analysis of user input.
Read the file one line at a time, and process each line one character at a time: with open(filename, "r") as f: for line in f: for c in line: process(c) But probably you want to process one *word* at a time; the easiest way (perhaps inaccurate) is to just split on whitespace: ... for word in line.split(): process(word) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list