Create a week03 subdirectory in your cs21/class directory:
% cd % cd cs21/class % pwd /home/your_user_name/cs21/class % mkdir week03Then, from within your week03 subdirectory copy over some python files from my public directory:
% cd week03 % pwd /home/your_user_name/cs21/class/week03 % cp ~newhall/public/cs21/week03/* . % ls ascii.py drop_letter.py format.py is_odd.py what_is_it.py
$ python ascii.py Enter a phrase: hello there h : 104 e : 101 l : 108 l : 108 o : 111 : 32 t : 116 h : 104 e : 101 r : 114 e : 101
This program takes as input a string and produces a new string cosisting of every other (even) character from the first Enter a phrase: I love computer science! The modified string is: Ilv optrsine
Once you get that working add code to check that the user correctly entered just a single character. If not, then print out an error message saying that the input is bad and quit the program by making a call to the exit function:
print "bad input" # come up with a better message than this exit()
Once you get that to work, lets add code to first check to see if the input value entered by the user is a valid int (e.g. the string "hello" is not a valid int value). If the input is not valid, print out an error message and exits. If it is valid, then print out a message indicating if it is an odd or even number.