+ 1
I have tried multiple paths to the pig Latin problem and the 1st & 2nd attempts work not sure what I'm missing
#first attempt string = input() def piglatin(word): slice1 = slice(1) word2 = word[slice1] word = word.replace(word2,'') word3 = word + word2 + 'ay' return word3 string = string.split() string2 = [] for y in string: x = piglatin(y) string2.append(x) string2 = ' '.join(string2) print(string2) # second attempt string = input() def piglatin(word): slice1 = slice(1) word2 = word[slice1] word = word.replace(word2,'') word3 = word + word2 + 'ay' return word3 string = string.split() string2 = list(map(piglatin,string)) string2 = ' '.join(string2) print(string2)
4 Respostas
+ 6
Nick Accordino ,
if both versions are working, what is your issue?
+ 2
They work on the 1st, 2nd and 4th attempts but not the 3rd and 5th and it won't show me those attempts. They are locked
+ 2
The replace function replaces all occurrances in the string. That is default behavior if you don't specify the third argument. Give it a third argument of 1, which specifies that you want only one replacement.
+ 2
Thank you very much for the help that fixed it