For python please Pig Latin is a simple language game where

For python please.

Pig Latin is a simple language game where words are changed according to simple rules. Write a program that prompts the user to enter a word. Your program should print the corresponding Pig Latin word based on these two rules: If the word starts with a consonant, move it to the end of the word and add \"ay\" (e.g., happy - appyhay) If the word starts with a vowel, just add \"yay\" to the end of the word.

Solution

Code:

w = input(\"Enter a word: \")
wo = w
vowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]
if(w[0] in vowels):
   w = w + \"yay\"
else:
   w = w[1:]+w[:1]+\"ay\"
print(\"Pig Latin word of \'%s\' is \'%s\'.\"%(wo,w))  

Output:

For python please. Pig Latin is a simple language game where words are changed according to simple rules. Write a program that prompts the user to enter a word.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site