[Tutor] Re: While loops

Emile van Sebille emile@fenx.com
Thu Nov 7 08:25:02 2002


"Dan Dud" <wheelcrdan@hotmail.com> wrote in message
news:F75ZtP0kvdIBirXXeQM000004aa@hotmail.com...
>
>
>
>
> Hello Everyone.
>
> I have a question about while loops..  I'm using python 2.2.2, and I'm
on
> chapter 7 in "How to think like a computer scientist" The part I'm
stuck on
> is 7.3 the only way I can make it work is to spell banana like
> 'b','a','n','a','n','a' I will print one letter per line. Like the
example
> shows, but I doesn't show spelling banana like that. How do I make
this
> work??? Also how do I print them in reverse??? I've tried to say
>
> print fruit
> fruit.reverse()
> print fruit
>
> but it will only print banana on one line.. What am I doing wrong??
Thanks
> for everyone help and talk to you all again soon...


A string is a sequence of characters that you can convert to a list, so
start with:

fruit = list("banana")

and the rest will work out.

If you've got something started using while, post what you've got so far
so we can see what ]you're trying, otherwise I wouldn't consider while
in this situation.

HTH,


--

Emile van Sebille
emile@fenx.com

---------