<br><br><div><span class="gmail_quote">On 6/18/06, <b class="gmail_sendername">Josh F</b> <<a href="mailto:jj_frap@hotmail.com">jj_frap@hotmail.com</a>> 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("Enter your message:")<br>print message[-1::-1]</blockquote><div><br>just another noob here.<br>but wouldn't his way work like this:<br>
<br>>>>message = "foobar"<br>>>>for i in range(len(message)-1,-1,-1):<br>... 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>>Message: 1<br>>Date: Sun, 18 Jun 2006 05:58:38 -0500
<br>>From: "Bill Tatum" <<a href="mailto:btatum@cddn.com">btatum@cddn.com</a>><br>>Subject: [Tutor] Beginner question(s)<br>>To: <<a href="mailto:tutor@python.org">tutor@python.org</a>><br>>Message-ID: <
<a href="mailto:20060618105838.0DB326318@mem01.ecsis.net">20060618105838.0DB326318@mem01.ecsis.net</a>><br>>Content-Type: text/plain; charset="us-ascii"<br>><br>>Hi,<br>><br>><br>><br>>I'm working through Python Programming for the Absolute Beginner. One of
<br>>the challenges at the end of chapter 4 is to get a message from the user<br>>and<br>>then print it out backwards. I have.<br>><br>><br>><br>>message = raw_input("Enter your message:")<br>
><br>>count = len(message)<br>><br>>print count<br>><br>><br>><br>>which gives me the number of characters in the message. I tried to use a<br>>for loop:<br>><br>><br>><br>>for i in range(len(message)-1,-1, -1):
<br>><br>> print i,<br>><br>><br>><br>>but I just get the numeric values of the string. Can anyone help?<br>><br>><br>><br>>Also, does anyone know of a PDA that would run python?<br>>
<br>><br>><br>>TIA<br><br><br>_______________________________________________<br>Tutor maillist - <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