<div class="gmail_quote">On Wed, Mar 23, 2011 at 9:55 AM, Lezlie Kline <span dir="ltr"><<a href="mailto:lezlie.kline@gmail.com">lezlie.kline@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Tony,<br><br>For your question "What's the checksum for a completely empty message (i.e., no characters at all)?" Do you mean the value or how do I write it? I would think the value would be 0.<br>
</blockquote>
<div>Correct. Now think of that as your starting point; any message containing characters is going to start at 0 plus the sum of the ASCII values of each of its characters. Where would you store the initial value of an empty message?</div>
<div> </div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">My understanding of where I'm storing the ASCII values for each letter is ord(message[i])<br></blockquote>
<div>ord isn't a variable, it's a function. It's calculating the ASCII value of the i-th character of "message".</div>
<div> </div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">I don't think it's been initialized properly, but that's where I don't understand about the accumulator for strings. I originally thought this for the accumulator:<br>
<br>output=""<br>for i in range(len(message[i])"
<div class="im"><br> print"The value of message[i] is ", message[i]<br></div> output=output+" " + ord(message[i])
<div class="im"><br> print"The value of the message is ", output<br><br></div>but strings and integers don't concatentate AND my ord(value) isn't accumulating AND I thing my output is getting overwritten. <br>
</blockquote>
<div>You don't want to mix apples and oranges. Your variable "message" contains a full name in the test case, "John X. Doe", for example, so it's made up of characters. What should the accumulator contain, if you're going to be adding numbers?</div>
<div> </div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Here's part of the problem. The person "teaching" me Python provides some information and then jumps to the programs so I'm struggling in the fuzzy dark. I was given the range "for i in range(len(message[i]):print"The value of message[i] is ", message[i]" and I understand that it obtains the length of my message, but I don't really understand the [i] part other than [i] represents integer and the "i" in for i is the iteration of the loop so when you ask the question "message[i] will provide you the character at position i. What are you doing with it?" I'm not sure what you're asking?<br>
<br>I'm sorry to be so dense. Believe it or not I've been working on this program for a week....<br><font color="#888888"><br>L.</font> </blockquote>
<div> </div>
<div>Is this homework?</div>
<div> </div>
<div>Tony R.</div>
<div> </div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>
<div class="h5">
<div class="gmail_quote">On Wed, Mar 23, 2011 at 9:30 AM, taserian <span dir="ltr"><<a href="mailto:taserian@gmail.com" target="_blank">taserian@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="gmail_quote">
<div>On Wed, Mar 23, 2011 at 9:09 AM, Lezlie Kline <span dir="ltr"><<a href="mailto:lezlie.kline@gmail.com" target="_blank">lezlie.kline@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hi,<br><br>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.<br>
<br>def main():<br> print"This program creates a checksum for a message."<br> name=raw_input("Please enter the message to encode: ")<br> message=name<br> output=name<br> for i in range(len(message)):<br>
print"The value of message[i] is ", message[i]<br> output=output+name+ord(message[i])<br> print"The value of the message is ", output<br> checksum=(output)%256<br> print"The checksum is ", checksum<br>
<br>main()<br></blockquote></div>
<div>I'd like to give you some pointers so you can solve it yourself:</div>
<div> </div>
<div>What's the checksum for a completely empty message (i.e., no characters at all)?</div>
<div>Where are you storing the (ASCII) values of each letter? Has it been initialized properly?</div>
<div>
<div> </div>
<blockquote style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">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:<br>
<br>print message<br>get input<br>find length<br>using length in range function accumulate ASCII numbers<br>calculate checksum<br>print checksum<br><br>I'd appreciate any help offered as I'm "pulling out my hair."</blockquote>
<div> </div></div>
<div>message[i] will provide you the character at position i. What are you doing with it?</div>
<div> </div>
<div>Tony R.</div></div></blockquote></div><br></div></div></blockquote></div><br>