Feb-13-2018, 10:11 PM
(This post was last modified: Feb-13-2018, 10:11 PM by bjorntobias.)
Hi guys,
I'm trying to take an input value, a quote, and place each word of that quote into a new line when printed. I'm not really succesful with that. Rather than placing each work on a new line it just appends each word to the new line.
which results in
they
they stumble
they stumble who
they stumble who run
they stumble who run fast
But I would like it to print,
they
stumble
who
run
fast
Any tips and trix for solving this?
Thanks a lot,
Tobias
I'm trying to take an input value, a quote, and place each word of that quote into a new line when printed. I'm not really succesful with that. Rather than placing each work on a new line it just appends each word to the new line.
1 2 3 4 5 6 7 8 9 10 |
# [ ] Print each word in the quote on a new line quote = "they stumble who run fast" start = 0 space_index = quote.find( " " ) while space_index ! = - 1 : print (quote[:space_index]) space_index = quote.find( " " , space_index + 1 ) |
they
they stumble
they stumble who
they stumble who run
they stumble who run fast
But I would like it to print,
they
stumble
who
run
fast
Any tips and trix for solving this?
Thanks a lot,
Tobias