[Tutor] can any one help

Luke Paireepinart rabidpoobear at gmail.com
Sun Jan 31 23:21:53 CET 2010


On Sun, Jan 31, 2010 at 3:27 PM, invincible patriot <
invincible_patriot at hotmail.com> wrote:

>  thanks for the reply
> i did one question
> i will tel u my progress in another question n then u tel me that what next
> must be done
>
> thanks
>
> Write a small Python program that generates the list of all pairs of
> characters c and
> its doubling 2 c, where c moves through all the letters of the string
> "foobar" and prints it out.
> The result will look like:
> [(’f’, ’ff’), (’o’, ’oo’), (’o’, ’oo’), (’b’, ’bb’), (’a’, ’aa’), (’r’,
> ’rr’)]
>
> thatz the question
> i think that first i woulf take a string 'foobar'
> convert it into a list
> take itz length
> n then do indexing
> and then multiply using for loop
>
> herez my code
>
> a='foobar'
> b=list(a)
> print b
>
> ['f','o','o','b','a','r']
>
> c=len(b)
> 6
>
>
> thatz where i am
> now i wana do the indexing of each character so that i use for loop n
> multply each character with 2
>
>
See now that you have provided us with what you've tried we can help you a
little more.
How do you think you should do the multiplication?  You mentioned a 'for
loop' but you didn't actually try using one in your code.

Also one hint, strings can be used directly in this situation.
as an example,
a = 'foobar'
len(a)
6

You don't actually have to convert it to a list before iterating over it.

-Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100131/61cadaec/attachment.htm>


More information about the Tutor mailing list