[Tutor] silly question
Jason Child
jasonchild at cnsp.com
Thu Dec 23 00:16:59 CET 2004
sorry everyone, I figured it out on my own ;)
Jason Child wrote:
> Alan Gauld wrote:
>
>>>oops, I forgot to add the s = 1 and s=0 lines to the example code i
>>>posted...
>>>
>>>
>>
>>OK, To save us guessing, why don't you post it with the s=1/0 and
>>also the actual output pattern you get?
>>
>>Seeing the error is a very powerful technique for guessing what may
>>be at fault. A second hand description is never as precise.
>>
>>Alan G
>>
>>
>>
> I've got a silly question.
> #######################
> P1 = "prefix1"
> P2 = "prefix2"
>
> def my_func(list, items):
> s = 0
> out = ""
> for i in range(len(list)):
> if s == 0:
> p = P1
> s = 1
> else:
> p = P2
> s = 0
> for j in range(len(items)):
> out += p +items[j]
> return out
> ########################
>
> If my input was:
> list = ["car list 1","car list 2"]
> items = ["torino","mustang","elantra"]
>
> for output I get:
> prefix1torinoprefix1mustangprefix1elantraprefix1torinoprefix1mustangprefix1elantra
>
> when I expect:
> prefix1torinoprefix1mustangprefix1elantra*prefix2*torino*prefix2*mustang*prefix2*elantra
>
>
>--
>Jason Christopher Child
>
>Computer Network Service Professionals
>VOZ Online
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
More information about the Tutor
mailing list