[Tutor] Checksum program
taserian at gmail.com
Wed Mar 23 14:30:01 CET 2011
On Wed, Mar 23, 2011 at 9:09 AM, Lezlie Kline <lezlie.kline at gmail.com>wrote:
> I'm trying to work out the bugs in a program for calculating the checksum
> (modulo 256) of an input string. I'm testing it with my full name and I'm a
> beginner with Python. Here's what I have so far.
> def main():
> print"This program creates a checksum for a message."
> name=raw_input("Please enter the message to encode: ")
> for i in range(len(message)):
> print"The value of message[i] is ", message[i]
> print"The value of the message is ", output
> print"The checksum is ", checksum
I'd like to give you some pointers so you can solve it yourself:
What's the checksum for a completely empty message (i.e., no characters at
Where are you storing the (ASCII) values of each letter? Has it been
> I know I'm offbase somewhere, but I'm not understanding some parts of the
> accumulator part of the program. I need it to work with the message[i]
> intact. In other words, I need the pseudo code to go something like this:
> print message
> get input
> find length
> using length in range function accumulate ASCII numbers
> calculate checksum
> print checksum
> I'd appreciate any help offered as I'm "pulling out my hair."
message[i] will provide you the character at position i. What are you doing
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor