+ 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)

1st Jan 2022, 3:39 PM
Nick Accordino
Nick Accordino - avatar
4 Réponses
+ 6
Nick Accordino , if both versions are working, what is your issue?
1st Jan 2022, 4:36 PM
Lothar
Lothar - avatar
+ 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
1st Jan 2022, 4:49 PM
Nick Accordino
Nick Accordino - avatar
+ 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.
2nd Jan 2022, 2:00 AM
Brian
Brian - avatar
+ 2
Thank you very much for the help that fixed it
2nd Jan 2022, 2:13 AM
Nick Accordino
Nick Accordino - avatar