replace
while (count < total):
name_is = text.find("is")+3
text = text[name_is:100]
where_is = text.find(" ")
print text[0:where_is]
count = count + 1
with
tag = DIV() # or PRE()
while (count < total):
name_is = text.find("is")+3
text = text[name_is:100]
where_is = text.find(" ")
tag.append(text[0:where_is]+'\n")
count = count + 1
then {{=tag}}
On Saturday, 13 October 2012 09:13:32 UTC-5, Mrq wrote:
>
> Hi,
>
> How do I print all results from a while loop to a view page?
>
> Code example:
> text = "Mothers name is Maria \n Fathers name is Josef \n Childsname is
> Jesus "
> total = text.count("is")
> count = 0
> where_is = 0
> name_is = 0
>
> while (count < total):
> name_is = text.find("is")+3
> text = text[name_is:100]
> where_is = text.find(" ")
> print text[0:where_is]
> count = count + 1
>
>
> This give results:
> Maria
> Josef
> Jesus
>
> If I replace "print text[0:where_is]" with "return
> dict(message=(text[0:where_is]))"
> and have a view with code "{{=message}}" It will only give result "Maria"
> to the webpage.
>
> Is it possible to do this without code all this into the view?
>
> Thanks in advance !
>
--