Beginner question(s)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Beginner question(s)

Bill Tatum

Hi,

 

I’m working through Python Programming for the Absolute Beginner.  One of the challenges at the end of chapter 4 is to get a message from the user and then print it out backwards. I have…

 

message = raw_input("Enter your message:")

count = len(message)

print count

 

which gives me the number of characters in the message.  I tried to use a for loop:

 

for i in range(len(message)-1,-1, -1):

    print i,

 

but I just get the numeric values of the string.  Can anyone help?

 

Also, does anyone know of a PDA that would run python? 

 

TIA

 


_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Beginner question(s)

Michael Sullivan-10
On Sun, 2006-06-18 at 05:58 -0500, Bill Tatum wrote:

> Hi,
>
>  
>
> I’m working through Python Programming for the Absolute Beginner.  One
> of the challenges at the end of chapter 4 is to get a message from the
> user and then print it out backwards. I have…
>
>  
>
> message = raw_input("Enter your message:")
>
> count = len(message)
>
> print count
>
>  
>
> which gives me the number of characters in the message.  I tried to
> use a for loop:
>
>  
>
> for i in range(len(message)-1,-1, -1):
>
>     print i,
>
>  
>
> but I just get the numeric values of the string.  Can anyone help?
>

I'm a python beginner myself, but shouldn't that last "print i" be "print message[i]?  As it stands, you're only printing the numeric value 'i'.
-Michael Sullivan-


_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Beginner question(s)

Alan Gauld-4
In reply to this post by Bill Tatum
> message = raw_input("Enter your message:")
> for i in range(len(message)-1,-1, -1):
>    print i,
>
> but I just get the numeric values of the string.  Can anyone help?

As an alternative approach consider converting to a list and
using the reverse method...

> Also, does anyone know of a PDA that would run python?  

There was a project called pippy, but I haven't heard anything of it
recently so I don't know if its still around or if it runs on modern
PDAs - I think it was PalmOS anyhow...

There was rumours of a Pocket Windows version too but
I've never really been interested in that one...

Alan G.

_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Beginner question(s)

Ismael Garrido
Alan Gauld wrote:
>> Also, does anyone know of a PDA that would run python?  
>>    
>
> There was a project called pippy, but I haven't heard anything of it
> recently so I don't know if its still around or if it runs on modern
> PDAs - I think it was PalmOS anyhow...
>
>  

Pippy is quite dead. No development done recently. It supposedly runs
fine, but runs only Python 1.5.

If you want it, it's at:
http://sourceforge.net/projects/pippy

Ismael
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Beginner question(s)

John Fouhy
In reply to this post by Bill Tatum
> Also, does anyone know of a PDA that would run python?

Some of the new Nokias run python: http://www.forum.nokia.com/python

--
John.
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: Beginner question(s)

David Rock
In reply to this post by Ismael Garrido
* Ismael Garrido <[hidden email]> [2006-06-18 19:34]:

> Alan Gauld wrote:
> >> Also, does anyone know of a PDA that would run python?  
> >>    
> >
> > There was a project called pippy, but I haven't heard anything of it
> > recently so I don't know if its still around or if it runs on modern
> > PDAs - I think it was PalmOS anyhow...
> >
> >  
>
> Pippy is quite dead. No development done recently. It supposedly runs
> fine, but runs only Python 1.5.

Last I used it, it worked fine, but it was limited.

--
David Rock
[hidden email]
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor