# Filename: redact.py # Author: Brian L. Walter # Description of contents: # A simple program that replaces digits in an input string with Xs. def main(): # Welcome the user. print ("\nI'm in the mood to redact something!") # Get the string to redact. input = raw_input("\nPlease enter a string you'd like to clean up: \n") # Initialize DIGITS, the sequence of forbidden characters. DIGITS = "1234567890" # Initialize output, the accumulator variable for the output. output = "" # Consider each character of the input in turn, either adding it # to the output (if it's not a digit) or adding an X to the output # (if it is a digit). for char in input: if char in DIGITS: output += "X" else: output += char # Print out the results. print "\nHere's the version we'll show the press:" print output # Wait for the user to hit enter before exiting. raw_input("\nHit enter to exit.") main()