[Tutor] Python backwards program

Feziwe Mpondo feziwe at sanbi.ac.za
Wed Apr 13 17:14:46 CEST 2005


Alberto Troiano wrote:

> You can do this:
>
> >>> word=raw_input("Type the word: ")
> Type the word: Kokiri Forest
> >>> print word
> Kokiri Forest
> >>> print word[::-1]
> tseroF irikoK
>
> But I saw that this gave you a hard time so this is an alternate 
> longer way:
>
> >>> backword=""
> >>> counter=len(word)
>
> >>> while counter!=0:
>              backword+=word[counter-1]
>              counter-=1
>
> >>> print backword
> tseroF irikoK
>
> So choose the one you want and feel free to ask in case of any doubt
>
> Regards
>
> Alberto
>
>
>  Gaucho
> >From: "Jim and Laura Ahl" <jcahl at psci.net> >To: <tutor at python.org> 
> >Subject: [Tutor] Python backwards program >Date: Tue, 12 Apr 2005 
> 20:05:41 -0500 > >I am very new to programming and I have an 
> assignment to have a raw_input string that is inputted by the user and 
> then is printed backwards. Can anyone help me? I can get it to print 
> regular but backwards in not working. > >Thank You >Jim 
> >_______________________________________________ >Tutor maillist - 
> Tutor at python.org >http://mail.python.org/mailman/listinfo/tutor
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>  
>
i am able to type, what i can't seem to do is seeing it print or 
executing the command on the shell window


More information about the Tutor mailing list