<br><br><div><span class="gmail_quote">On 6/18/06, <b class="gmail_sendername">Josh F</b> &lt;<a href="mailto:jj_frap@hotmail.com">jj_frap@hotmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
re. Beginner Question<br><br>I'm still in the fairly early stages of learning Python, but I have an<br>intermediate level of HTML, CSS, and VB6 knowledge along with the<br>fundamentals of C and C++ and a very little bit of PERL..
<br><br>But enough about me...Here's the solution.<br><br>message = raw_input(&quot;Enter your message:&quot;)<br>print message[-1::-1]</blockquote><div><br>just another noob here.<br>but wouldn't his way work like this:<br>
<br>&gt;&gt;&gt;message = &quot;foobar&quot;<br>&gt;&gt;&gt;for i in range(len(message)-1,-1,-1):<br>... &nbsp;&nbsp;&nbsp; print message[i],<br>...<br>r a b o o f<br><br>i guess there's lots of ways to do it. <br>that's my 2 cents.<br>
</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Slicing a string takes three arguments, all of which are optional: The first<br>character to be sliced, the last character to be sliced, and tio slice every
<br>nth character.<br><br>In Python strings, -1 refers to the last character in the string and thus<br>becomes the first argument.<br><br>You don't specify the second argument because you're printing the string<br>from end to beginning.
<br><br>Finallly, the -1 in the 3rd argument indicates that you want the string to<br>be printed in reverse order (i.e. iterate backwards by one character).<br><br><br><br><br><br><br><br>&gt;Message: 1<br>&gt;Date: Sun, 18 Jun 2006 05:58:38 -0500
<br>&gt;From: &quot;Bill Tatum&quot; &lt;<a href="mailto:btatum@cddn.com">btatum@cddn.com</a>&gt;<br>&gt;Subject: [Tutor] Beginner question(s)<br>&gt;To: &lt;<a href="mailto:tutor@python.org">tutor@python.org</a>&gt;<br>&gt;Message-ID: &lt;
<a href="mailto:20060618105838.0DB326318@mem01.ecsis.net">20060618105838.0DB326318@mem01.ecsis.net</a>&gt;<br>&gt;Content-Type: text/plain; charset=&quot;us-ascii&quot;<br>&gt;<br>&gt;Hi,<br>&gt;<br>&gt;<br>&gt;<br>&gt;I'm working through Python Programming for the Absolute Beginner.&nbsp;&nbsp;One of
<br>&gt;the challenges at the end of chapter 4 is to get a message from the user<br>&gt;and<br>&gt;then print it out backwards. I have.<br>&gt;<br>&gt;<br>&gt;<br>&gt;message = raw_input(&quot;Enter your message:&quot;)<br>
&gt;<br>&gt;count = len(message)<br>&gt;<br>&gt;print count<br>&gt;<br>&gt;<br>&gt;<br>&gt;which gives me the number of characters in the message.&nbsp;&nbsp;I tried to use a<br>&gt;for loop:<br>&gt;<br>&gt;<br>&gt;<br>&gt;for i in range(len(message)-1,-1, -1):
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; print i,<br>&gt;<br>&gt;<br>&gt;<br>&gt;but I just get the numeric values of the string.&nbsp;&nbsp;Can anyone help?<br>&gt;<br>&gt;<br>&gt;<br>&gt;Also, does anyone know of a PDA that would run python?<br>&gt;
<br>&gt;<br>&gt;<br>&gt;TIA<br><br><br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">
http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br><br clear="all"><br>-- <br>Daniel McQuay<br><a href="mailto:simplebob@gmail.com">simplebob@gmail.com</a><br><a href="http://boxster.homelinux.org">
boxster.homelinux.org</a><br>H: 814.825.0847<br>M: 814-341-6233