Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Description: PYGLATIN
- Break It Down
- Now let’s take what we’ve learned so far and write a Pig Latin translator.
- Pig Latin is a language game, where you move the first letter of the word to the end and add “ay.” So “Python” becomes “ythonpay.” To write a Pig Latin translator in Python, here are the steps we’ll need to take:
- Ask the user to input a word in English.
- Make sure the user entered a valid word.
- Convert the word from English to Pig Latin.
- Display the translation result."
- word = raw_input("Provide me correct word please:")
- lenght = len(word)
- if lenght >=2:
- if (word[lenght-lenght]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- if (word[(lenght-lenght)+1]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- if((lenght-lenght)+2<=lenght):
- if (word[(lenght-lenght)+2]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- if((lenght-lenght)+3<=lenght):
- if (word[(lenght-lenght)+3]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- if((lenght-lenght)+4<=lenght):
- if (word[(lenght-lenght)+4]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- if((lenght-lenght)+5<=lenght):
- if (word[(lenght-lenght)+5]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- if((lenght-lenght)+6<=lenght):
- if (word[(lenght-lenght)+6]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- if((lenght-lenght)+7<=lenght):
- if (word[(lenght-lenght)+7]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- if((lenght-lenght)+8<=lenght):
- if (word[(lenght-lenght)+8]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- if((lenght-lenght)+9<=lenght):
- if (word[(lenght-lenght)+9]== 'a' or 'A' or 'b' or 'B' or 'c' or 'C' or 'd' or 'D' or 'e' or 'E' or 'f' or 'F' or 'g' or 'G' or 'h' or 'H' or 'i' or 'I' or 'J' or 'j' or 'K' or 'k' or 'l' or 'L' or 'm' or 'M' or 'n' or 'N' or 'o' or 'O' or 'p' or 'P' or 'r' or 'R' or 's' or 'S' or 't' or 'T' or 'u' or 'U' or 'w' or 'W' or 'y' or 'Y' or 'z' or 'Z'):
- a=word[0]
- word[0]=" "
- word = word + a + "ay"
- print(word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement