11.11 Pig Translator newbie program with Bugs


hi guys, after days of head breaking on python, i managed to run this on my own without cheating but i would like to receive critique , as a newbie it will be useful for my future programming. thank you and here is your :hamburger:

<Below this line, add a link to the EXACT exercise that you are stuck at.>
<In what way does your code behave incorrectly? Include ALL error messages.>
there is some minor bugs and place to more further
<What do you expect to happen instead?>
i want it to be usefull and ability to control not only one word


simply written Pig translator, have fun with your
new language and skills of communication.

if you remove [2:] from mutant_word[2:] at print you gain ability to change last 2 letters of any given
word with you added letters, as i could’t find anything that can as function can take last right chars
of word and change only them , it will be usefull i guess.

print “write your word to translate it into Piggy”

changeable_Add = “ya” # you can change it

def pig():
word = raw_input() # word that user inputs or writes in prompt dialog
if len(word) > 1 and word.isalpha(): # it defines if user inputs real ‘Word’
new_word_reverced = word[::-1] # i reverced whole inputted word
new_word = new_word_reverced.replace(new_word_reverced[0:2],str(changeable_Add)) #and then replaced first 2 letters
#of newly created reverced word
mutant_word = new_word[::-1] #and here i reverce back the changed reverced word
print ("your new word is: " + mutant_word[2:]) # this line prints newly created word without first 2 letters
print (“try to write only one word PLEASE!”)
return pig() # this line return function from beginning if user added some *** rather then word

print pig() # calling function

“”" bugs are in changeable_Add and repeated inputs"""

<do not remove the three backticks above>

this bit of code:

        print ("try to write only one word PLEASE!")
        return pig() 

i wouldn’t return pig(), since then a value is returned,and the function ends (does ir prompt again?), i would simply do:

        print ("try to write only one word PLEASE!")

This way, your function get called again. And the user gets a new change to enter someting

hi stetim94, i tried both with return and without return in pyscripter and the same result, if user adds number the program runs again in both versions. could you explain what is the main difference in this part? thank you for taking time and looking through the code

Okay, without running the code i would say, if you do use return pig(), the result of the function call is returned, but i would have to test it.