Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.82 KB | None | 0 0
  1. Description: PYGLATIN
  2. Break It Down
  3. Now let’s take what we’ve learned so far and write a Pig Latin translator.
  4.  
  5. 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:
  6.  
  7. Ask the user to input a word in English.
  8. Make sure the user entered a valid word.
  9. Convert the word from English to Pig Latin.
  10. Display the translation result."
  11.  
  12.  
  13.  
  14.  
  15. word = raw_input("Provide me correct word please:")
  16. lenght = len(word)
  17.  
  18. if lenght >=2:
  19.  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'):
  20.    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'):
  21.      if((lenght-lenght)+2<=lenght):
  22.        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'):
  23.          if((lenght-lenght)+3<=lenght):
  24.            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'):
  25.              if((lenght-lenght)+4<=lenght):
  26.                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'):
  27.                  if((lenght-lenght)+5<=lenght):
  28.                    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'):
  29.                      if((lenght-lenght)+6<=lenght):
  30.                        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'):
  31.                          if((lenght-lenght)+7<=lenght):
  32.                            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'):
  33.                              if((lenght-lenght)+8<=lenght):
  34.                                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'):
  35.                                  if((lenght-lenght)+9<=lenght):
  36.                                    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'):
  37.                                      a=word[0]
  38.                                      word[0]=" "
  39.                                      word = word + a + "ay"
  40.                                      print(word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement