dimanche 30 mars 2014

For loop stops after 1st case


Vote count:

0




I have a for loop that goes through each word in a string and returns a modified string.


However, the loop stops after the first word.


The summarized code looks like this:



def format(x):
return x
def modify(string):
for x in words:
if statement:
return x[v:] + x[:v] + "xx"
else:
return x + "xx"
def final(string):
return format(modify(string))


The format function format what modify does, while the final function puts everything together. It works perfect for the first word in the string, but stops after that.


Current input and output:



>>>final("This is a test case")
>>>>Htisxx


What I want:



>>>final("This is a test case")
>>>>Htisxx isxx axx esttxx asecxx


Why does the loop stop? How can I fix this?



asked 31 secs ago






Aucun commentaire:

Enregistrer un commentaire