![]() |
|
[Python] Quik insight on his Pig Latin translator??? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Quik insight on his Pig Latin translator??? (/showthread.php?tid=4545238) |
Quik insight on his Pig Latin translator??? - Gpx45 - Nov 19, 2014 Hey guys, I made this translator which converts regular words int pig latin which basically is taking the first letter putting it at the end of the word and adding "ay" now this is the script: Code pyg = 'ay'ok its works 100% however the professor wants something very specific that I don't quite understand and I really need help because its killing the cells!!!! This is what he said: "It looks like you printed the correct translation of "dog", but make sure to set new_word equal to the slice as well." "dog the word i had put in to translate?" it came out "ogday" Now I don't understand what that means??? does he mean make another variable called "new_word" again and equal it to the list of the slice??? * - MoonCakeRuler - Nov 19, 2014 The 'slice' he mentions is this - [1:len(new_word)]. He basically wants you to set new_word equal to the final result. You can do either of these: Code new_word = new_word[1:]Or, you can just do it when you set new_word like this: Code new_word = (word + first + pyg)[1:]Also, you don't need to use len(new_word). You can just do [1:] to get all the elements from 1st index onwards. Cheers. * - Gpx45 - Nov 19, 2014 (Nov 19, 2014 04:56 PM)MoonCakeRuler Wrote: The 'slice' he mentions is this - [1:len(new_word)]. He basically wants you to set new_word equal to the final result. Ahhh I fucking see it its so simple fuck!!! yes!! thanks MoonCake!! * - Brandon1027 - Nov 22, 2014 I've made my own Pig Latin translator that is pretty easy to follow through. Feel free to use this if you decide that you like this one better. Code original = raw_input('Type in a word').lower()* - Zezil - Nov 22, 2014 Rofl, you talked about an instructor... This is exactly one of the very early Python lessons on codeacademy. :P |